blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 7
332
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
50
| license_type
stringclasses 2
values | repo_name
stringlengths 7
115
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 557
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
684M
⌀ | star_events_count
int64 0
77.7k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 17
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 82
values | src_encoding
stringclasses 28
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
5.41M
| extension
stringclasses 11
values | content
stringlengths 7
5.41M
| authors
listlengths 1
1
| author
stringlengths 0
161
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
cfba7f89761ab513c412c1e7cc61d049ec062803 | 32bf257d6ec328d301aee9d91c26c4d0074ca124 | /belajar-java-dasar/src/SwapVariable.java | 04432297517a5ea223a68fe4db1fd1d96f9fa8a8 | []
| no_license | MatchaBear/JavaNeighborhood | 82a5735f035643a01aa56341ba54ce513bf98583 | 6e5e1505e8a49ebd59f117a3dbeb6036a052a49c | refs/heads/main | 2023-03-30T02:11:18.326977 | 2021-03-19T06:41:59 | 2021-03-19T06:41:59 | 335,013,582 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 782 | java | public class SwapVariable {
public static void main(String[] args) {
int a, b, f;
a = 1;
f = a;
var c = "Hello World";
var g = c;
System.out.println("c = " + c);
System.out.println("f = " + f);
a = 2;
System.out.println("a = " + a);
System.out.println("f = " + f);
System.out.println(g);
int v1, v2, temp1, temp2;
v1 = 1;
v2 = 2;
temp1 = v1;
temp2 = v2;
v1 = temp2;
v2 = temp1;
System.out.println(v1);
System.out.println(v2);
int v3, v4, temp;
v3 = 3;
v4 = 4;
temp = v3;
v3 = v4;
v4 = temp;
System.out.println(v3);
System.out.println(v4);
}
}
| [
"[email protected]"
]
| |
720c736198745c69252e1f34fe380773590d31db | 410335c5c9a60a2376fda10cce0e13b1a9eb3404 | /src/main/java/com/opensource/productservice/dto/Coupon.java | c419e92cd2ab85df00c3da54f4cdd3a94f77a66b | []
| no_license | open-source-hub-ak/productservice | 189b150352bc36c71d061ed37f3d04352e57695e | 8662e7c90ed75cc02115f92b4d220056b69a77fa | refs/heads/main | 2023-02-27T09:49:03.943781 | 2021-01-31T18:19:04 | 2021-01-31T18:19:04 | 334,663,025 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 801 | java | package com.opensource.productservice.dto;
import java.math.BigDecimal;
public class Coupon {
private Long id;
private String code;
private BigDecimal discount;
private String expDate;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public BigDecimal getDiscount() {
return discount;
}
public void setDiscount(BigDecimal discount) {
this.discount = discount;
}
public String getExpDate() {
return expDate;
}
public void setExpDate(String expDate) {
this.expDate = expDate;
}
@Override
public String toString() {
return "Coupon [id=" + id + ", code=" + code + ", discount=" + discount + ", expDate=" + expDate + "]";
}
}
| [
"aakash"
]
| aakash |
920dffe9bd837771cd09fda4078f33dec2b91110 | 64d3f86f759281241ec1dbecb20b56341a306243 | /src/test/GameManager.java | 573ba9c419fe439a754d78bfd4593792e9f03821 | []
| no_license | hgn1027/server | 1d11db911e4bb2d559ba018e8a67b28e5d9503ef | 7bffcf664ab2168f79a8792910156fa173e512aa | refs/heads/master | 2020-05-05T06:28:56.925231 | 2019-04-06T05:27:23 | 2019-04-06T05:27:23 | 179,789,870 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 620 | java | package test;
import java.util.ArrayList;
public class GameManager {
private ArrayList<Game> gameList = new ArrayList<Game> ();
public void addGame (Game game) {
gameList.add(game);
}
public Game findGame (String roomName) {
for (Game game : gameList) {
if (game.getRoomName().compareTo(roomName) == 0 )
return game;
}
return null;
}
public String[] getRoomList () {
String[] roomList = new String[gameList.size()];
for (int i = 0; i < gameList.size(); i++) {
roomList[i] = gameList.get(i).getRoomName();
}
return roomList;
}
}
//
| [
"[email protected]"
]
| |
16edb5e5c19b4e5813d5f5d3cef0acdf6e5b1edc | fec2ff45e8a30d6e5a777d83d2348087e4d0cc42 | /tasks/calculate_Levenshtein_Distance/Solution.java | ac7cbd9863a747e1f7a681b2baefc16a2ab4c45a | []
| no_license | YuryMazniou/JavaHomeWork | 6f912610345b03a9efec3b2df22a9947b684d2f6 | 0873060a15dfb47a21bddb304eb9af2e70701024 | refs/heads/master | 2020-05-02T05:25:22.170273 | 2019-05-18T12:37:15 | 2019-05-18T12:37:15 | 177,771,328 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,409 | java | package by.it.mazniou.tasks.calculate_Levenshtein_Distance;
import java.util.Arrays;
/*
будет возвращать true, если возможно изменить/добавить/удалить один символ в одной из строк и получить другую.
*/
public class Solution {
public static void main(String[] args) {
System.out.println(isOneEditAway("qwertyui","qwertyu"));
}
public static boolean isOneEditAway(String first, String second) {
if(first.equals(second))return true;
if(Math.abs(first.length()-second.length())>=2)return false;
return calculate(first,second)<=1?true:false;
}
static int calculate(String x, String y) {
if (x.isEmpty()) {
return y.length();
}
if (y.isEmpty()) {
return x.length();
}
int substitution = calculate(x.substring(1), y.substring(1))
+ costOfSubstitution(x.charAt(0), y.charAt(0));
int insertion = calculate(x, y.substring(1)) + 1;
int deletion = calculate(x.substring(1), y) + 1;
return min(substitution, insertion, deletion);
}
public static int costOfSubstitution(char a, char b) {
return a == b ? 0 : 1;
}
public static int min(int... numbers) {
return Arrays.stream(numbers)
.min().orElse(Integer.MAX_VALUE);
}
}
| [
"[email protected]"
]
| |
65804d32cf38afc0a32bff7ae06369d3f53316a2 | d57f02a4904b1ed349eb5f7f1276dd2bd5e92aef | /src/main/java/Model/ChangedColorType.java | 61aa697a532d456d65fb6905e25fae6af9c2bc2a | []
| no_license | MyLovePoppet/Tetris | 710e1accf04ced9a2ba51c01e3c9ceeeec79ef5c | 114bf03d802d0f8647e7395d488656dbb7360485 | refs/heads/master | 2022-11-11T20:34:25.392896 | 2020-06-24T07:19:47 | 2020-06-24T07:19:47 | 264,567,891 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,760 | java | package Model;
import java.util.ArrayList;
import java.util.List;
/**
* 位置i,j变化前后的颜色数据
*/
public class ChangedColorType {
//在位置i,j处
public final int i, j;
//前后的颜色变化
public final TetrisColorType oldColor;
public final TetrisColorType newColor;
public ChangedColorType(int i, int j, TetrisColorType oldColor, TetrisColorType newColor) {
this.i = i;
this.j = j;
this.oldColor = oldColor;
this.newColor = newColor;
}
/**
* 遍历所有的颜色值,找出变化前后的数据
* @param oldModel 旧的颜色数据类型
* @param newModel 新的颜色数据类型
* @return 所有的变化的颜色数据
*/
public static List<ChangedColorType> getChangedColorType(TetrisDataModel oldModel, TetrisDataModel newModel) {
List<ChangedColorType> changedColorTypes = new ArrayList<>();
TetrisColorType[][] colors_old = oldModel.getColors();
TetrisColorType[][] colors_new = newModel.getColors();
//进行遍历寻找
for (int i = 0; i < colors_old.length; i++) {
for (int j = 0; j < colors_old[0].length; j++) {
//颜色不同,加入到最后的List内
if (colors_old[i][j] != colors_new[i][j]) {
changedColorTypes.add(new ChangedColorType(i, j, colors_old[i][j], colors_new[i][j]));
}
}
}
return changedColorTypes;
}
@Override
public String toString() {
return "ChangedColorType{" +
"i=" + i +
", j=" + j +
", oldColor=" + oldColor +
", newColor=" + newColor +
'}';
}
}
| [
"[email protected]"
]
| |
400a0d779ed50fd08781bf81daab8bfee9ffc8fc | 0e027b4fa1e77adb25aef60c0a3e9cf4bb4e49c7 | /src/main/java/com/hsy/mybatis/controller/ExamineController.java | e73da3b46988b7ffcae09d6a2ccfde7bb023192a | []
| no_license | krispyhan/modleWorkChecker | 13ad0d6759c1de93e50e28fee84372de846fc0df | 1e69e970b0838d293d9b3c34b6702393e8922cfc | refs/heads/master | 2023-05-11T14:16:34.417170 | 2021-06-03T14:54:55 | 2021-06-03T14:54:55 | 334,601,237 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,106 | java | package com.hsy.mybatis.controller;
import com.hsy.mybatis.service.IExamineService;
import com.hsy.mybatis.util.WebJsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
@RestController
@RequestMapping("/examine")
public class ExamineController {
@Autowired
private IExamineService examineService;
@RequestMapping("/confirmExamine_{id}_{result}")
public WebJsonResult confirmExamine(@PathVariable int id, @PathVariable int result){
examineService.confirmExamine(id, result);
return WebJsonResult.newSuccess("操作成功!");
}
@RequestMapping("/checkExamine_{initiative}_{passive}")
public String checkExamine(@PathVariable String initiative,@PathVariable String passive){
if(examineService.checkExamine(initiative, passive)){
return "success";
}
return "failure";
}
}
| [
"[email protected]"
]
| |
8e941ee3a3453a3fee93260d84274e4d014a4baa | 7b5b5d311f5609356aa47a8fe31d5e95dee6f42c | /commons/src/main/java/org/archive/util/ms/DefaultBlockFileSystem.java | 3c70021ba8f3c905aaaa77321044d51905e62ccc | []
| no_license | BertrandDechoux/Heritrix-3 | 26307664a76e692d17c16fac5a4f2909cfeb32c8 | ea49e55c892a888ef9a601ec0ead1dabdb154e40 | refs/heads/master | 2016-09-11T01:20:35.460985 | 2010-12-09T22:28:20 | 2010-12-09T22:28:20 | 1,179,450 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,950 | java | /*
* This file is part of the Heritrix web crawler (crawler.archive.org).
*
* Licensed to the Internet Archive (IA) by one or more individual
* contributors.
*
* The IA licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.archive.util.ms;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Map;
import org.archive.io.SeekInputStream;
import org.archive.util.ArchiveUtils;
import org.archive.util.LRU;
/**
* Default implementation of the Block File System.
*
* <p>The overall structure of a BlockFileSystem file (such as a .doc file) is
* as follows. The file is divided into blocks, which are of uniform length
* (512 bytes). The first block (at file pointer 0) is called the header
* block. It's used to look up other blocks in the file.
*
* <p>Subfiles contained within the .doc file are organized using a Block
* Allocation Table, or BAT. The BAT is basically a linked list; given a
* block number, the BAT will tell you the next block number. Note that
* the header block has no number; block #0 is the first block after the
* header. Thus, to convert a block number to a file pointer:
* <code>int filePointer = (blockNumber + 1) * BLOCK_SIZE</code>.
*
* <p>The BAT itself is discontinuous, however. To find the blocks that
* comprise the BAT, you have to look in the header block. The header block
* contains an array of 109 pointers to the blocks that comprise the BAT.
* If more than 109 BAT blocks are required (in other words, if the .doc
* file is larger than ~6 megabytes), then something called the
* XBAT comes into play.
*
* <p>XBAT blocks contain pointers to the 110th BAT block and beyond.
* The first XBAT block is stored at a file pointer listed in the header.
* The other XBAT blocks are always stored in order after the first; the
* XBAT table is continuous. One is inclined to wonder why the BAT itself
* is not so stored, but oh well.
*
* <p>The BAT only tells you the next block for a given block. To find the
* first block for a subfile, you have to look up that subfile's directory
* entry. Each directory entry is a 128 byte structure in the file, so four
* of them fit in a block. The number of the first block of the entry list
* is stored in the header. To find subsequent entry blocks, the BAT must
* be used.
*
* <p>I'm telling you all this so that you understand the caching that this
* class provides.
*
* <p>First, directory entries are not cached. It's assumed that they will
* be looked up at the beginning of a lengthy operation, and then forgotten
* about. This is certainly the case for {@link Doc#getText(BlockFileSystem)}.
* If you need to remember directory entries, you can manually store the Entry
* objects in a map or something, as they don't grow stale.
*
* <p>This class keeps all 512 bytes of the header block in memory at all
* times. This prevents a potentially expensive file pointer repositioning
* every time you're trying to figure out what comes next.
*
* <p>BAT and XBAT blocks are stored in a least-recently used cache. The
* <i>n</i> most recent BAT and XBAT blocks are remembered, where <i>n</i>
* is set at construction time. The minimum value of <i>n</i> is 1. For small
* files, this can prevent file pointer repositioning for BAT look ups.
*
* <p>The BAT/XBAT cache only takes up memory as needed. If the specified
* cache size is 100 blocks, but the file only has 4 BAT blocks, then only
* 2048 bytes will be used by the cache.
*
* <p>Note this class only caches BAT and XBAT blocks. It does not cache the
* blocks that actually make up a subfile's contents. It is assumed that those
* blocks will only be accessed once per operation (again, this is what
* {Doc.getText(BlockFileSystem)} typically requires.)
*
* @author pjack
* @see http://jakarta.apache.org/poi/poifs/fileformat.html
*/
public class DefaultBlockFileSystem implements BlockFileSystem {
/**
* Pointers per BAT block.
*/
final private static int POINTERS_PER_BAT = 128;
/**
* Size of a BAT pointer in bytes. (In other words, 4).
*/
final private static int BAT_POINTER_SIZE = BLOCK_SIZE / POINTERS_PER_BAT;
/**
* The number of BAT pointers in the header block. After this many
* BAT blocks, the XBAT blocks must be consulted.
*/
final private static int HEADER_BAT_LIMIT = 109;
/**
* The size of an entry record in bytes.
*/
final private static int ENTRY_SIZE = 128;
/**
* The number of entries that can fit in a block.
*/
final private static int ENTRIES_PER_BLOCK = BLOCK_SIZE / ENTRY_SIZE;
/**
* The .doc file as a stream.
*/
private SeekInputStream input;
/**
* The header block.
*/
private HeaderBlock header;
/**
* Cache of BAT and XBAT blocks.
*/
private Map<Integer,ByteBuffer> cache;
/**
* Constructor.
*
* @param input the file to read from
* @param batCacheSize number of BAT and XBAT blocks to cache
* @throws IOException if an IO error occurs
*/
public DefaultBlockFileSystem(SeekInputStream input, int batCacheSize)
throws IOException {
this.input = input;
byte[] temp = new byte[BLOCK_SIZE];
ArchiveUtils.readFully(input, temp);
this.header = new HeaderBlock(ByteBuffer.wrap(temp));
this.cache = new LRU<Integer,ByteBuffer>(batCacheSize);
}
public Entry getRoot() throws IOException {
// Position to the first block of the entry list.
int block = header.getEntriesStart();
input.position((block + 1) * BLOCK_SIZE);
// The root entry is always entry #0.
return new DefaultEntry(this, input, 0);
}
/**
* Returns the entry with the given number.
*
* @param entryNumber the number of the entry to return
* @return that entry, or null if no such entry exists
* @throws IOException if an IO error occurs
*/
Entry getEntry(int entryNumber) throws IOException {
// Entry numbers < 0 typically indicate an end-of-stream.
if (entryNumber < 0) {
return null;
}
// It's impossible to check against the upper bound, because the
// upper bound is not recorded anywhere.
// Advance to the block containing the desired entry.
int blockCount = entryNumber / ENTRIES_PER_BLOCK;
int remainder = entryNumber % ENTRIES_PER_BLOCK;
int block = header.getEntriesStart();
for (int i = 0; i < blockCount; i++) {
block = getNextBlock(block);
}
if (block < 0) {
// Given entry number exceeded the number of available entries.
return null;
}
int filePos = (block + 1) * BLOCK_SIZE + remainder * ENTRY_SIZE;
input.position(filePos);
return new DefaultEntry(this, input, entryNumber);
}
public int getNextBlock(int block) throws IOException {
if (block < 0) {
return block;
}
// Index into the header array of BAT blocks.
int headerIndex = block / POINTERS_PER_BAT;
// Index within that BAT block of the block we're interested in.
int batBlockIndex = block % POINTERS_PER_BAT;
int batBlockNumber = batLookup(headerIndex);
ByteBuffer batBlock = getBATBlock(batBlockNumber);
return batBlock.getInt(batBlockIndex * BAT_POINTER_SIZE);
}
/**
* Looks up the block number of a BAT block.
*
* @param headerIndex
* @return
* @throws IOException
*/
private int batLookup(int headerIndex) throws IOException {
if (headerIndex < HEADER_BAT_LIMIT + 1) {
return header.getBATBlockNumber(headerIndex);
}
// Find the XBAT block of interest
headerIndex -= HEADER_BAT_LIMIT;
int xbatBlockNumber = headerIndex / POINTERS_PER_BAT;
xbatBlockNumber += header.getExtendedBATStart();
ByteBuffer xbat = getBATBlock(xbatBlockNumber);
// Find the bat Block number inside the XBAT block
int xbatBlockIndex = headerIndex % POINTERS_PER_BAT;
return xbat.getInt(xbatBlockIndex * BAT_POINTER_SIZE);
}
/**
* Returns the BAT block with the given block number.
* If the BAT block were previously cached, then the cached version
* is returned. Otherwise, the file pointer is repoisitioned to
* the start of the given block, and the 512 bytes are read and
* stored in the cache.
*
* @param block the block number of the BAT block to return
* @return the BAT block
* @throws IOException
*/
private ByteBuffer getBATBlock(int block) throws IOException {
ByteBuffer r = cache.get(block);
if (r != null) {
return r;
}
byte[] buf = new byte[BLOCK_SIZE];
input.position((block + 1) * BLOCK_SIZE);
ArchiveUtils.readFully(input, buf);
r = ByteBuffer.wrap(buf);
r.order(ByteOrder.LITTLE_ENDIAN);
cache.put(block, r);
return r;
}
public SeekInputStream getRawInput() {
return input;
}
}
| [
"gojomo@daa5b2f2-a927-0410-8b2d-f5f262fa301a"
]
| gojomo@daa5b2f2-a927-0410-8b2d-f5f262fa301a |
ce552b5a1899a5a3221cfff75e313f984e3cdb44 | 69506591d5a83c88a0ea993072b7415cd58caa61 | /src/main/java/com/thunisoft/service/impl/MasterDataServiceImpl.java | 6d2ca30a91fcfe18565aba203b4954c26a8d44b7 | []
| no_license | majiajue/masterdata | 3bb80ae1dbe59cafd055e8b4d87c82c7363fdc23 | 4c2cdd002c55eb100b61769462912b7956283e23 | refs/heads/master | 2020-12-10T23:47:20.092854 | 2019-11-04T07:49:49 | 2019-11-04T07:49:49 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,347 | java | package com.thunisoft.service.impl;
import com.thunisoft.dao.ApplicationReiewMapper;
import com.thunisoft.dao.MasterContentMapper;
import com.thunisoft.dao.MenuMapper;
import com.thunisoft.pojo.ApplicationReiew;
import com.thunisoft.pojo.MasterContent;
import com.thunisoft.pojo.Menu;
import com.thunisoft.service.MasterDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class MasterDataServiceImpl implements MasterDataService {
@Autowired
private MenuMapper menuMapper;
@Autowired
private MasterContentMapper masterContentMapper;
@Autowired
private ApplicationReiewMapper applicationReiewMapper;
@Override
public List<Menu> findAllByPid(Integer pId) {
List<Menu> menuList = menuMapper.findAllByPid(pId);
for (Menu menu:menuList) {
menu.setChildMenus(menuMapper.findAllByPid(menu.getId()));
}
return menuList;
}
@Override
public List<MasterContent> findByMenuId(Integer menuId) {
List<MasterContent> mcList=masterContentMapper.findByMenuId(menuId);
return mcList;
}
@Override
public List<MasterContent> findMasterContent(Integer limit, Integer page, Integer menuId) {
return masterContentMapper.findMasterContent(limit,page,menuId);
}
@Override
public int findCountByMenuId(Integer menuId) {
return masterContentMapper.findCountByMenuId(menuId);
}
@Override
public int insertMasterData(MasterContent mc) {
if (masterContentMapper.insert(mc)>0){
return mc.getId();
}else {
return 0;
}
}
@Override
public int insertApplicationReiew(ApplicationReiew ar) {
return applicationReiewMapper.insert(ar);
}
@Override
public List<Map> findExMasterData(Integer limit, Integer page,Integer status) {
return masterContentMapper.findExMasterData(limit,page,status);
}
@Override
public int findExMasterDataCount(Integer status) {
return masterContentMapper.findExMasterDataCount(status);
}
@Override
public int updateExaminDataById(ApplicationReiew appRe) {
return applicationReiewMapper.updateByPrimaryKey(appRe);
}
}
| [
"[email protected]"
]
| |
424732a20fecb03a2056b449b846b85c0c34ff42 | ed77cac4e30a7222ba7037ddbf664e7059a210bf | /presto-hive/src/test/java/io/prestosql/plugin/hive/metastore/alluxio/TestAlluxioHiveMetastoreConfig.java | 3b6673e371832285a277d409e97770957b0e5e12 | [
"Apache-2.0"
]
| permissive | treasure-data/presto | ff85ed1056c307ec8aef055f8db8f6224ef7c269 | 3d4749994847e75059923436e6d3ce6914babf2b | refs/heads/master | 2023-07-24T15:50:57.665143 | 2023-02-21T14:29:12 | 2023-02-21T14:29:12 | 14,758,597 | 11 | 2 | Apache-2.0 | 2019-02-07T05:34:45 | 2013-11-27T20:44:49 | Java | UTF-8 | Java | false | false | 1,641 | 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 io.prestosql.plugin.hive.metastore.alluxio;
import com.google.common.collect.ImmutableMap;
import org.testng.annotations.Test;
import java.util.Map;
import static io.airlift.configuration.testing.ConfigAssertions.assertFullMapping;
import static io.airlift.configuration.testing.ConfigAssertions.assertRecordedDefaults;
import static io.airlift.configuration.testing.ConfigAssertions.recordDefaults;
public class TestAlluxioHiveMetastoreConfig
{
@Test
public void testDefaults()
{
assertRecordedDefaults(recordDefaults(AlluxioHiveMetastoreConfig.class)
.setMasterAddress(null));
}
@Test
public void testExplicitPropertyMapping()
{
Map<String, String> properties = new ImmutableMap.Builder<String, String>()
.put("hive.metastore.alluxio.master.address", "localhost:19998")
.build();
AlluxioHiveMetastoreConfig expected = new AlluxioHiveMetastoreConfig()
.setMasterAddress("localhost:19998");
assertFullMapping(properties, expected);
}
}
| [
"[email protected]"
]
| |
12cac55fd4473f49f82ded87c9714874d6985835 | 3244b6517b44be887bf2e74e248db269bdbee2ef | /android/Virgilio_Guida_Tv/src/com/mscg/virgilio/adapters/DBAnalyzeListItemAdapter.java | ec70ebcc6e22809afd8672983d7071f27a01e01e | []
| no_license | mscg82/opencms-backoffice | fb7a6a20150b78f24f32bb9980ecd8e3258d8119 | 9392cd02e4a969899755a7ba29f171c68685d136 | refs/heads/master | 2021-01-19T06:59:20.023026 | 2012-06-17T14:08:31 | 2012-06-17T14:08:31 | 32,315,793 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,532 | java | package com.mscg.virgilio.adapters;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.content.Context;
import android.database.Cursor;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ResourceCursorAdapter;
import com.mscg.virgilio.R;
import com.mscg.virgilio.VirgilioGuidaTvDbAnalyze;
import com.mscg.virgilio.database.ProgramsDB;
import com.mscg.virgilio.listener.AnalyzeDBClickListener;
public class DBAnalyzeListItemAdapter extends ResourceCursorAdapter {
private SimpleDateFormat dateFormat;
public DBAnalyzeListItemAdapter(Context context, int layout, Cursor c, boolean autoRequery) {
super(context, layout, c, autoRequery);
dateFormat = new SimpleDateFormat(context.getString(R.string.complete_day_format));
}
public DBAnalyzeListItemAdapter(Context context, int layout, Cursor c) {
this(context, layout, c, true);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View view = super.newView(context, cursor, parent);
Holder holder = new Holder();
holder.listener = new AnalyzeDBClickListener(context, ((VirgilioGuidaTvDbAnalyze) context).getGuiHandler());
holder.dayName = (Button) view.findViewById(R.id.analyze_db_elem_day);
holder.dayName.setOnClickListener(holder.listener);
holder.selected = (CheckBox) view.findViewById(R.id.analyze_db_elem_select);
holder.selected.setOnCheckedChangeListener(holder.listener);
view.setTag(holder);
return view;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
Holder holder = (Holder) view.getTag();
holder.id = cursor.getLong(ProgramsDB.PROGRAMS_CONSTS.ID_COL_INDEX);
long time = cursor.getLong(ProgramsDB.PROGRAMS_CONSTS.DATE_COL_INDEX);
holder.date = new Date(time);
holder.dayName.setText(dateFormat.format(holder.date));
holder.dayName.setTag(holder);
boolean checked = ((VirgilioGuidaTvDbAnalyze) context).isElementChecked(holder.id);
holder.selected.setChecked(checked);
holder.listener.setProgramID(holder.id);
}
public class Holder {
public Button dayName;
public CheckBox selected;
public long id;
public Date date;
public AnalyzeDBClickListener listener;
}
}
| [
"[email protected]@47385934-2c28-11de-874f-bb9810f3bc79"
]
| [email protected]@47385934-2c28-11de-874f-bb9810f3bc79 |
7b96f6f854eb84ad45780da2a6ebfe1c47bc0465 | 1bddd4ad0757362409c24e5a56d5b4ae5fb7f998 | /src/java/main/org/apache/zookeeper/server/ZooKeeperServer.java | 22ff875b4c15c8307f98747275f4deda3af9f6e0 | [
"Apache-2.0"
]
| permissive | leonardo-DG/CatKeeper | 0e498e4549d0083f3efaeb33950b40154bf59cdb | 11a5f15b9eae6ec893892e9895ba44784528e533 | refs/heads/master | 2016-09-08T00:24:02.346352 | 2014-11-29T06:38:02 | 2014-11-29T06:38:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 37,045 | java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.zookeeper.server;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.nio.charset.Charset;
import java.nio.charset.CharsetDecoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Random;
import javax.security.sasl.SaslException;
import org.apache.jute.BinaryInputArchive;
import org.apache.jute.BinaryOutputArchive;
import org.apache.jute.Record;
import org.apache.zookeeper.Environment;
import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.KeeperException.Code;
import org.apache.zookeeper.KeeperException.SessionExpiredException;
import org.apache.zookeeper.ZooDefs.OpCode;
import org.apache.zookeeper.data.ACL;
import org.apache.zookeeper.data.Id;
import org.apache.zookeeper.data.StatPersisted;
import org.apache.zookeeper.jmx.MBeanRegistry;
import org.apache.zookeeper.proto.AuthPacket;
import org.apache.zookeeper.proto.ConnectRequest;
import org.apache.zookeeper.proto.ConnectResponse;
import org.apache.zookeeper.proto.GetSASLRequest;
import org.apache.zookeeper.proto.NotifySpecialNode;
import org.apache.zookeeper.proto.ReplyHeader;
import org.apache.zookeeper.proto.RequestHeader;
import org.apache.zookeeper.proto.SetSASLResponse;
import org.apache.zookeeper.proto.UpdateTimeout;
import org.apache.zookeeper.server.DataTree.ProcessTxnResult;
import org.apache.zookeeper.server.RequestProcessor.RequestProcessorException;
import org.apache.zookeeper.server.ServerCnxn.CloseRequestException;
import org.apache.zookeeper.server.SessionTracker.Session;
import org.apache.zookeeper.server.SessionTracker.SessionExpirer;
import org.apache.zookeeper.server.auth.AuthenticationProvider;
import org.apache.zookeeper.server.auth.ProviderRegistry;
import org.apache.zookeeper.server.persistence.FileTxnSnapLog;
import org.apache.zookeeper.server.quorum.ReadOnlyZooKeeperServer;
import org.apache.zookeeper.txn.CreateSessionTxn;
import org.apache.zookeeper.txn.TxnHeader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* This class implements a simple standalone ZooKeeperServer. It sets up the
* following chain of RequestProcessors to process requests:
* PrepRequestProcessor -> SyncRequestProcessor -> FinalRequestProcessor
*/
public class ZooKeeperServer implements SessionExpirer, ServerStats.Provider {
protected static final Logger LOG;
static {
LOG = LoggerFactory.getLogger(ZooKeeperServer.class);
Environment.logEnv("Server environment:", LOG);
}
protected ZooKeeperServerBean jmxServerBean;
protected DataTreeBean jmxDataTreeBean;
//public ZookeeperDynamicTimeout zdt;
/**
* The server delegates loading of the tree to an instance of the interface
*/
public interface DataTreeBuilder {
public DataTree build();
}
static public class BasicDataTreeBuilder implements DataTreeBuilder {
public DataTree build() {
return new DataTree();
}
}
public static final int DEFAULT_TICK_TIME = 3000;
protected int tickTime = DEFAULT_TICK_TIME;
/** value of -1 indicates unset, use default */
protected int minSessionTimeout = -1;
/** value of -1 indicates unset, use default */
protected int maxSessionTimeout = -1;
protected SessionTracker sessionTracker;
private FileTxnSnapLog txnLogFactory = null;
private ZKDatabase zkDb;
protected long hzxid = 0;
public final static Exception ok = new Exception("No prob");
protected RequestProcessor firstProcessor;
protected volatile boolean running;
protected String specialNode;
/**
* This is the secret that we use to generate passwords, for the moment it
* is more of a sanity check.
*/
static final private long superSecret = 0XB3415C00L;
int requestsInProcess;
final List<ChangeRecord> outstandingChanges = new ArrayList<ChangeRecord>();
// this data structure must be accessed under the outstandingChanges lock
final HashMap<String, ChangeRecord> outstandingChangesForPath =
new HashMap<String, ChangeRecord>();
private ServerCnxnFactory serverCnxnFactory;
private final ServerStats serverStats;
void removeCnxn(ServerCnxn cnxn) {
zkDb.removeCnxn(cnxn);
}
/**
* Creates a ZooKeeperServer instance. Nothing is setup, use the setX
* methods to prepare the instance (eg datadir, datalogdir, ticktime,
* builder, etc...)
*
* @throws IOException
*/
public ZooKeeperServer() {
serverStats = new ServerStats(this);
}
/**
* Creates a ZooKeeperServer instance. It sets everything up, but doesn't
* actually start listening for clients until run() is invoked.
*
* @param dataDir the directory to put the data
*/
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, int tickTime,
int minSessionTimeout, int maxSessionTimeout,
DataTreeBuilder treeBuilder, ZKDatabase zkDb) {
serverStats = new ServerStats(this);
this.txnLogFactory = txnLogFactory;
this.zkDb = zkDb;
this.tickTime = tickTime;
this.minSessionTimeout = minSessionTimeout;
this.maxSessionTimeout = maxSessionTimeout;
LOG.info("Created server with tickTime " + tickTime
+ " minSessionTimeout " + getMinSessionTimeout()
+ " maxSessionTimeout " + getMaxSessionTimeout()
+ " datadir " + txnLogFactory.getDataDir()
+ " snapdir " + txnLogFactory.getSnapDir());
}
/**
* creates a zookeeperserver instance.
* @param txnLogFactory the file transaction snapshot logging class
* @param tickTime the ticktime for the server
* @param treeBuilder the datatree builder
* @throws IOException
*/
public ZooKeeperServer(FileTxnSnapLog txnLogFactory, int tickTime,
DataTreeBuilder treeBuilder) throws IOException {
this(txnLogFactory, tickTime, -1, -1, treeBuilder,
new ZKDatabase(txnLogFactory));
}
public ServerStats serverStats() {
return serverStats;
}
public void dumpConf(PrintWriter pwriter) {
pwriter.print("clientPort=");
pwriter.println(getClientPort());
pwriter.print("dataDir=");
pwriter.println(zkDb.snapLog.getSnapDir().getAbsolutePath());
pwriter.print("dataLogDir=");
pwriter.println(zkDb.snapLog.getDataDir().getAbsolutePath());
pwriter.print("tickTime=");
pwriter.println(getTickTime());
pwriter.print("maxClientCnxns=");
pwriter.println(serverCnxnFactory.getMaxClientCnxnsPerHost());
pwriter.print("minSessionTimeout=");
pwriter.println(getMinSessionTimeout());
pwriter.print("maxSessionTimeout=");
pwriter.println(getMaxSessionTimeout());
pwriter.print("serverId=");
pwriter.println(getServerId());
}
/**
* This constructor is for backward compatibility with the existing unit
* test code.
* It defaults to FileLogProvider persistence provider.
*/
public ZooKeeperServer(File snapDir, File logDir, int tickTime)
throws IOException {
this( new FileTxnSnapLog(snapDir, logDir),
tickTime, new BasicDataTreeBuilder());
}
/**
* Default constructor, relies on the config for its agrument values
*
* @throws IOException
*/
public ZooKeeperServer(FileTxnSnapLog txnLogFactory,
DataTreeBuilder treeBuilder)
throws IOException
{
this(txnLogFactory, DEFAULT_TICK_TIME, -1, -1, treeBuilder,
new ZKDatabase(txnLogFactory));
}
/**
* get the zookeeper database for this server
* @return the zookeeper database for this server
*/
public ZKDatabase getZKDatabase() {
return this.zkDb;
}
/**
* set the zkdatabase for this zookeeper server
* @param zkDb
*/
public void setZKDatabase(ZKDatabase zkDb) {
this.zkDb = zkDb;
}
/**
* Restore sessions and data
*/
public void loadData() throws IOException, InterruptedException {
setZxid(zkDb.loadDataBase());
// Clean up dead sessions
LinkedList<Long> deadSessions = new LinkedList<Long>();
for (Long session : zkDb.getSessions()) {
if (zkDb.getSessionWithTimeOuts().get(session) == null) {
deadSessions.add(session);
}
}
zkDb.setDataTreeInit(true);
for (long session : deadSessions) {
// XXX: Is lastProcessedZxid really the best thing to use?
killSession(session, zkDb.getDataTreeLastProcessedZxid());
}
// Make a clean snapshot
takeSnapshot();
}
public void takeSnapshot(){
try {
txnLogFactory.save(zkDb.getDataTree(), zkDb.getSessionWithTimeOuts());
} catch (IOException e) {
LOG.error("Severe unrecoverable error, exiting", e);
// This is a severe error that we cannot recover from,
// so we need to exit
System.exit(10);
}
}
/**
* This should be called from a synchronized block on this!
*/
synchronized public long getZxid() {
return hzxid;
}
synchronized long getNextZxid() {
return ++hzxid;
}
synchronized public void setZxid(long zxid) {
hzxid = zxid;
}
long getTime() {
return System.currentTimeMillis();
}
private void close(long sessionId) {
submitRequest(null, sessionId, OpCode.closeSession, 0, null, null);
}
public void closeSession(long sessionId) {
LOG.info("Closing session 0x" + Long.toHexString(sessionId));
// we do not want to wait for a session close. send it as soon as we
// detect it!
close(sessionId);
}
protected void killSession(long sessionId, long zxid) {
zkDb.killSession(sessionId, zxid);
if (LOG.isTraceEnabled()) {
ZooTrace.logTraceMessage(LOG, ZooTrace.SESSION_TRACE_MASK,
"ZooKeeperServer --- killSession: 0x"
+ Long.toHexString(sessionId));
}
if (sessionTracker != null) {
sessionTracker.removeSession(sessionId);
}
}
public void expire(Session session) {
long sessionId = session.getSessionId();
LOG.info("Expiring session 0x" + Long.toHexString(sessionId)
+ ", timeout of " + session.getTimeout() + "ms exceeded");
close(sessionId);
}
public static class MissingSessionException extends IOException {
private static final long serialVersionUID = 7467414635467261007L;
public MissingSessionException(String msg) {
super(msg);
}
}
/**
* 判断会话 是否超期
*/
void touch(ServerCnxn cnxn) throws MissingSessionException {
if (cnxn == null) {
return;
}
long id = cnxn.getSessionId();
int to = cnxn.getSessionTimeout();
if (!sessionTracker.touchSession(id, to)) {
throw new MissingSessionException(
"No session with sessionid 0x" + Long.toHexString(id)
+ " exists, probably expired and removed");
}
}
protected void registerJMX() {
// register with JMX
try {
jmxServerBean = new ZooKeeperServerBean(this);
MBeanRegistry.getInstance().register(jmxServerBean, null);
try {
jmxDataTreeBean = new DataTreeBean(zkDb.getDataTree());
MBeanRegistry.getInstance().register(jmxDataTreeBean, jmxServerBean);
} catch (Exception e) {
LOG.warn("Failed to register with JMX", e);
jmxDataTreeBean = null;
}
} catch (Exception e) {
LOG.warn("Failed to register with JMX", e);
jmxServerBean = null;
}
}
public void startdata()
throws IOException, InterruptedException {
//check to see if zkDb is not null
if (zkDb == null) {
zkDb = new ZKDatabase(this.txnLogFactory);
}
if (!zkDb.isInitialized()) {
loadData();
}
}
public void startup() {
if (sessionTracker == null) {
createSessionTracker();
}
System.out.println("startSessionTracker");
startSessionTracker();
System.out.println("setupRequestProcessors");
setupRequestProcessors();
registerJMX();
synchronized (this) {
running = true;
notifyAll();
}
}
protected void setupRequestProcessors() {
RequestProcessor finalProcessor = new FinalRequestProcessor(this);
RequestProcessor syncProcessor = new SyncRequestProcessor(this,
finalProcessor);
((SyncRequestProcessor)syncProcessor).start();
firstProcessor = new PrepRequestProcessor(this, syncProcessor);
((PrepRequestProcessor)firstProcessor).start();
}
protected void createSessionTracker() {
//recovery session from DB
sessionTracker = new SessionTrackerImpl(this, zkDb.getSessionWithTimeOuts(), tickTime, 1);
System.out.println("createSessionTracker");
}
protected void startSessionTracker() {
((SessionTrackerImpl)sessionTracker).start();
}
public boolean isRunning() {
return running;
}
public void shutdown() {
LOG.info("shutting down");
// new RuntimeException("Calling shutdown").printStackTrace();
this.running = false;
// Since sessionTracker and syncThreads poll we just have to
// set running to false and they will detect it during the poll
// interval.
if (sessionTracker != null) {
sessionTracker.shutdown();
}
if (firstProcessor != null) {
firstProcessor.shutdown();
}
if (zkDb != null) {
zkDb.clear();
}
unregisterJMX();
}
protected void unregisterJMX() {
// unregister from JMX
try {
if (jmxDataTreeBean != null) {
MBeanRegistry.getInstance().unregister(jmxDataTreeBean);
}
} catch (Exception e) {
LOG.warn("Failed to unregister with JMX", e);
}
try {
if (jmxServerBean != null) {
MBeanRegistry.getInstance().unregister(jmxServerBean);
}
} catch (Exception e) {
LOG.warn("Failed to unregister with JMX", e);
}
jmxServerBean = null;
jmxDataTreeBean = null;
}
synchronized public void incInProcess() {
requestsInProcess++;
}
synchronized public void decInProcess() {
requestsInProcess--;
}
public int getInProcess() {
return requestsInProcess;
}
/**
* This structure is used to facilitate information sharing between PrepRP
* and FinalRP.
*/
static class ChangeRecord {
ChangeRecord(long zxid, String path, StatPersisted stat, int childCount,
List<ACL> acl) {
this.zxid = zxid;
this.path = path;
this.stat = stat;
this.childCount = childCount;
this.acl = acl;
}
long zxid;
String path;
StatPersisted stat; /* Make sure to create a new object when changing */
int childCount;
List<ACL> acl; /* Make sure to create a new object when changing */
@SuppressWarnings("unchecked")
ChangeRecord duplicate(long zxid) {
StatPersisted stat = new StatPersisted();
if (this.stat != null) {
DataTree.copyStatPersisted(this.stat, stat);
}
return new ChangeRecord(zxid, path, stat, childCount,
acl == null ? new ArrayList<ACL>() : new ArrayList(acl));
}
}
byte[] generatePasswd(long id) {
Random r = new Random(id ^ superSecret);
byte p[] = new byte[16];
r.nextBytes(p);
return p;
}
protected boolean checkPasswd(long sessionId, byte[] passwd) {
return sessionId != 0
&& Arrays.equals(passwd, generatePasswd(sessionId));
}
long createSession(ServerCnxn cnxn, byte passwd[], int timeout) {
long sessionId = sessionTracker.createSession(timeout);
Random r = new Random(sessionId ^ superSecret);
r.nextBytes(passwd);
ByteBuffer to = ByteBuffer.allocate(4);
to.putInt(timeout);
//decide session id
cnxn.setSessionId(sessionId);
submitRequest(cnxn, sessionId, OpCode.createSession, 0, to, null);
return sessionId;
}
/**
* set the owner of this session as owner
* @param id the session id
* @param owner the owner of the session
* @throws SessionExpiredException
*/
public void setOwner(long id, Object owner) throws SessionExpiredException {
sessionTracker.setOwner(id, owner);
}
protected void revalidateSession(ServerCnxn cnxn, long sessionId,
int sessionTimeout) throws IOException {
boolean rc = sessionTracker.touchSession(sessionId, sessionTimeout);
if (LOG.isTraceEnabled()) {
ZooTrace.logTraceMessage(LOG,ZooTrace.SESSION_TRACE_MASK,
"Session 0x" + Long.toHexString(sessionId) +
" is valid: " + rc);
}
finishSessionInit(cnxn, rc);
}
public void reopenSession(ServerCnxn cnxn, long sessionId, byte[] passwd,
int sessionTimeout) throws IOException {
if (!checkPasswd(sessionId, passwd)) {
finishSessionInit(cnxn, false);
} else {
revalidateSession(cnxn, sessionId, sessionTimeout);
}
}
public void finishSessionInit(ServerCnxn cnxn, boolean valid) {
// register with JMX
try {
if (valid) {
serverCnxnFactory.registerConnection(cnxn);
}
} catch (Exception e) {
LOG.warn("Failed to register with JMX", e);
}
try {
ConnectResponse rsp = new ConnectResponse(0, valid ? cnxn.getSessionTimeout()
: 0, valid ? cnxn.getSessionId() : 0, // send 0 if session is no
// longer valid
valid ? generatePasswd(cnxn.getSessionId()) : new byte[16]);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BinaryOutputArchive bos = BinaryOutputArchive.getArchive(baos);
bos.writeInt(-1, "len");
rsp.serialize(bos, "connect");
if (!cnxn.isOldClient) {
bos.writeBool(
this instanceof ReadOnlyZooKeeperServer, "readOnly");
}
baos.close();
ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
bb.putInt(bb.remaining() - 4).rewind();
cnxn.sendBuffer(bb);
if (!valid) {
LOG.info("Invalid session 0x"
+ Long.toHexString(cnxn.getSessionId())
+ " for client "
+ cnxn.getRemoteSocketAddress()
+ ", probably expired");
cnxn.sendBuffer(ServerCnxnFactory.closeConn);
} else {
LOG.info("Established session 0x"
+ Long.toHexString(cnxn.getSessionId())
+ " with negotiated timeout " + cnxn.getSessionTimeout()
+ " for client "
+ cnxn.getRemoteSocketAddress());
}
cnxn.enableRecv();
} catch (Exception e) {
LOG.warn("Exception while establishing session, closing", e);
cnxn.close();
}
/**
* after created session, notify the specialNode to client
*/
cnxn.sendSpecialNode(new ReplyHeader(-101,0,0), new NotifySpecialNode(specialNode), "specialNode");
WatchManager.initSpecialNodes(specialNode);
}
public void updateSession(ServerCnxn cnxn, long to) {
//notify client
/*try {
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
}
public void closeSession(ServerCnxn cnxn, RequestHeader requestHeader) {
closeSession(cnxn.getSessionId());
}
public long getServerId() {
return 0;
}
public SessionTracker getSessionTracker(){
return this.sessionTracker;
}
/**
* @param cnxn
* @param sessionId
* @param xid
* @param bb
*/
private void submitRequest(ServerCnxn cnxn, long sessionId, int type,
int xid, ByteBuffer bb, List<Id> authInfo) {
Request si = new Request(cnxn, sessionId, xid, type, bb, authInfo);
submitRequest(si);
}
public void submitRequest(Request si) {
if (firstProcessor == null) {
synchronized (this) {
try {
while (!running) {
wait(1000);
}
} catch (InterruptedException e) {
LOG.warn("Unexpected interruption", e);
}
if (firstProcessor == null) {
throw new RuntimeException("Not started");
}
}
}
try {
touch(si.cnxn);
boolean validpacket = Request.isValid(si.type);
if (validpacket) {
firstProcessor.processRequest(si);
if (si.cnxn != null) {
incInProcess();
}
} else {
LOG.warn("Dropping packet at server of type " + si.type);
// if invalid packet drop the packet.
}
} catch (MissingSessionException e) {
if (LOG.isDebugEnabled()) {
LOG.debug("Dropping request: " + e.getMessage());
}
} catch (RequestProcessorException e) {
LOG.error("Unable to process request:" + e.getMessage(), e);
}
}
public static int getSnapCount() {
String sc = System.getProperty("zookeeper.snapCount");
try {
return Integer.parseInt(sc);
} catch (Exception e) {
return 100000;
}
}
public int getGlobalOutstandingLimit() {
String sc = System.getProperty("zookeeper.globalOutstandingLimit");
int limit;
try {
limit = Integer.parseInt(sc);
} catch (Exception e) {
limit = 1000;
}
return limit;
}
public void setServerCnxnFactory(ServerCnxnFactory factory) {
serverCnxnFactory = factory;
}
public ServerCnxnFactory getServerCnxnFactory() {
return serverCnxnFactory;
}
/**
* return the last proceesed id from the
* datatree
*/
public long getLastProcessedZxid() {
return zkDb.getDataTreeLastProcessedZxid();
}
/**
* return the outstanding requests
* in the queue, which havent been
* processed yet
*/
public long getOutstandingRequests() {
return getInProcess();
}
/**
* trunccate the log to get in sync with others
* if in a quorum
* @param zxid the zxid that it needs to get in sync
* with others
* @throws IOException
*/
public void truncateLog(long zxid) throws IOException {
this.zkDb.truncateLog(zxid);
}
public int getTickTime() {
return tickTime;
}
public void setTickTime(int tickTime) {
LOG.info("tickTime set to " + tickTime);
this.tickTime = tickTime;
}
public int getMinSessionTimeout() {
return minSessionTimeout == -1 ? tickTime * 2 : minSessionTimeout;
}
public void setMinSessionTimeout(int min) {
LOG.info("minSessionTimeout set to " + min);
this.minSessionTimeout = min;
}
public int getMaxSessionTimeout() {
return maxSessionTimeout == -1 ? tickTime * 20 : maxSessionTimeout;
}
public void setMaxSessionTimeout(int max) {
LOG.info("maxSessionTimeout set to " + max);
this.maxSessionTimeout = max;
}
public int getClientPort() {
return serverCnxnFactory != null ? serverCnxnFactory.getLocalPort() : -1;
}
public void setTxnLogFactory(FileTxnSnapLog txnLog) {
this.txnLogFactory = txnLog;
}
public FileTxnSnapLog getTxnLogFactory() {
return this.txnLogFactory;
}
public String getState() {
return "standalone";
}
public void dumpEphemerals(PrintWriter pwriter) {
zkDb.dumpEphemerals(pwriter);
}
public String getSpecialNode() {
return specialNode;
}
public void setSpecialNode(String specialNode) {
this.specialNode = specialNode;
}
/**
* return the total number of client connections that are alive
* to this server
*/
public int getNumAliveConnections() {
return serverCnxnFactory.getNumAliveConnections();
}
public String decode(ByteBuffer buffer) {
Charset charset = null;
CharsetDecoder decoder = null;
CharBuffer charBuffer = null;
try {
charset = Charset.forName("UTF-8");
decoder = charset.newDecoder();
charBuffer = decoder.decode(buffer);
return charBuffer.toString();
} catch (Exception ex) {
System.out.println("decode error!");
return "";
}
}
public void processConnectRequest(ServerCnxn cnxn, ByteBuffer incomingBuffer) throws IOException {
//System.out.println("time: " + decode(incomingBuffer));
//incomingBuffer.flip();
BinaryInputArchive bia = BinaryInputArchive.getArchive(new ByteBufferInputStream(incomingBuffer));
ConnectRequest connReq = new ConnectRequest();
//解析 zookeeper 连接消息
connReq.deserialize(bia, "connect");
if (LOG.isDebugEnabled()) {
LOG.debug("Session establishment request from client "
+ cnxn.getRemoteSocketAddress()
+ " client's lastZxid is 0x"
+ Long.toHexString(connReq.getLastZxidSeen()));
}
boolean readOnly = false;
try {
readOnly = bia.readBool("readOnly");
cnxn.isOldClient = false;
} catch (IOException e) {
// this is ok -- just a packet from an old client which
// doesn't contain readOnly field
LOG.warn("Connection request from old client "
+ cnxn.getRemoteSocketAddress()
+ "; will be dropped if server is in r-o mode");
}
if (readOnly == false && this instanceof ReadOnlyZooKeeperServer) {
String msg = "Refusing session request for not-read-only client "
+ cnxn.getRemoteSocketAddress();
LOG.info(msg);
throw new CloseRequestException(msg);
}
if (connReq.getLastZxidSeen() > zkDb.dataTree.lastProcessedZxid) {
String msg = "Refusing session request for client "
+ cnxn.getRemoteSocketAddress()
+ " as it has seen zxid 0x"
+ Long.toHexString(connReq.getLastZxidSeen())
+ " our last zxid is 0x"
+ Long.toHexString(getZKDatabase().getDataTreeLastProcessedZxid())
+ " client must try another server";
LOG.info(msg);
throw new CloseRequestException(msg);
}
int sessionTimeout = connReq.getTimeOut();
byte passwd[] = connReq.getPasswd();
int minSessionTimeout = getMinSessionTimeout();
if (sessionTimeout < minSessionTimeout) {
sessionTimeout = minSessionTimeout;
}
int maxSessionTimeout = getMaxSessionTimeout();
if (sessionTimeout > maxSessionTimeout) {
sessionTimeout = maxSessionTimeout;
}
/**
* set session timeout
*/
cnxn.setSessionTimeout(sessionTimeout);
// We don't want to receive any packets until we are sure that the
// session is setup
cnxn.disableRecv();
long sessionId = connReq.getSessionId();
if (sessionId != 0) {
long clientSessionId = connReq.getSessionId();
LOG.info("Client attempting to renew session 0x"
+ Long.toHexString(clientSessionId)
+ " at " + cnxn.getRemoteSocketAddress());
serverCnxnFactory.closeSession(sessionId);
cnxn.setSessionId(sessionId);
reopenSession(cnxn, sessionId, passwd, sessionTimeout);
} else {
LOG.info("Client attempting to establish new session at "
+ cnxn.getRemoteSocketAddress());
/**
* notify sessionTracker
*/
createSession(cnxn, passwd, sessionTimeout);
}
}
public boolean shouldThrottle(long outStandingCount) {
if (getGlobalOutstandingLimit() < getInProcess()) {
return outStandingCount > 0;
}
return false;
}
public void processPacket(ServerCnxn cnxn, ByteBuffer incomingBuffer) throws IOException {
// We have the request, now process and setup for next
InputStream bais = new ByteBufferInputStream(incomingBuffer);
BinaryInputArchive bia = BinaryInputArchive.getArchive(bais);
RequestHeader h = new RequestHeader();
h.deserialize(bia, "header");
// Through the magic of byte buffers, txn will not be
// pointing
// to the start of the txn
incomingBuffer = incomingBuffer.slice();
if (h.getType() == OpCode.auth) {
LOG.info("got auth packet " + cnxn.getRemoteSocketAddress());
AuthPacket authPacket = new AuthPacket();
ByteBufferInputStream.byteBuffer2Record(incomingBuffer, authPacket);
String scheme = authPacket.getScheme();
AuthenticationProvider ap = ProviderRegistry.getProvider(scheme);
Code authReturn = KeeperException.Code.AUTHFAILED;
if(ap != null) {
try {
authReturn = ap.handleAuthentication(cnxn, authPacket.getAuth());
} catch(RuntimeException e) {
LOG.warn("Caught runtime exception from AuthenticationProvider: " + scheme + " due to " + e);
authReturn = KeeperException.Code.AUTHFAILED;
}
}
if (authReturn!= KeeperException.Code.OK) {
if (ap == null) {
LOG.warn("No authentication provider for scheme: "
+ scheme + " has "
+ ProviderRegistry.listProviders());
} else {
LOG.warn("Authentication failed for scheme: " + scheme);
}
// send a response...
ReplyHeader rh = new ReplyHeader(h.getXid(), 0,
KeeperException.Code.AUTHFAILED.intValue());
cnxn.sendResponse(rh, null, null);
// ... and close connection
cnxn.sendBuffer(ServerCnxnFactory.closeConn);
cnxn.disableRecv();
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("Authentication succeeded for scheme: "
+ scheme);
}
LOG.info("auth success " + cnxn.getRemoteSocketAddress());
ReplyHeader rh = new ReplyHeader(h.getXid(), 0,
KeeperException.Code.OK.intValue());
cnxn.sendResponse(rh, null, null);
}
return;
} else {
if (h.getType() == OpCode.sasl) {
Record rsp = processSasl(incomingBuffer,cnxn);
ReplyHeader rh = new ReplyHeader(h.getXid(), 0, KeeperException.Code.OK.intValue());
cnxn.sendResponse(rh,rsp, "response"); // not sure about 3rd arg..what is it?
}
else {
Request si = new Request(cnxn, cnxn.getSessionId(), h.getXid(),
h.getType(), incomingBuffer, cnxn.getAuthInfo());
si.setOwner(ServerCnxn.me);
submitRequest(si);
}
}
cnxn.incrOutstandingRequests(h);
}
private Record processSasl(ByteBuffer incomingBuffer, ServerCnxn cnxn) throws IOException {
LOG.debug("Responding to client SASL token.");
GetSASLRequest clientTokenRecord = new GetSASLRequest();
ByteBufferInputStream.byteBuffer2Record(incomingBuffer,clientTokenRecord);
byte[] clientToken = clientTokenRecord.getToken();
LOG.debug("Size of client SASL token: " + clientToken.length);
byte[] responseToken = null;
try {
ZooKeeperSaslServer saslServer = cnxn.zooKeeperSaslServer;
try {
// note that clientToken might be empty (clientToken.length == 0):
// if using the DIGEST-MD5 mechanism, clientToken will be empty at the beginning of the
// SASL negotiation process.
responseToken = saslServer.evaluateResponse(clientToken);
if (saslServer.isComplete() == true) {
String authorizationID = saslServer.getAuthorizationID();
LOG.info("adding SASL authorization for authorizationID: " + authorizationID);
cnxn.addAuthInfo(new Id("sasl",authorizationID));
}
}
catch (SaslException e) {
LOG.warn("Client failed to SASL authenticate: " + e);
if ((System.getProperty("zookeeper.allowSaslFailedClients") != null)
&&
(System.getProperty("zookeeper.allowSaslFailedClients").equals("true"))) {
LOG.warn("Maintaining client connection despite SASL authentication failure.");
} else {
LOG.warn("Closing client connection due to SASL authentication failure.");
cnxn.close();
}
}
}
catch (NullPointerException e) {
LOG.error("cnxn.saslServer is null: cnxn object did not initialize its saslServer properly.");
}
if (responseToken != null) {
LOG.debug("Size of server SASL response: " + responseToken.length);
}
// wrap SASL response token to client inside a Response object.
return new SetSASLResponse(responseToken);
}
public ProcessTxnResult processTxn(TxnHeader hdr, Record txn) {
ProcessTxnResult rc;
int opCode = hdr.getType();
long sessionId = hdr.getClientId();
rc = getZKDatabase().processTxn(hdr, txn);
if (opCode == OpCode.createSession) {
if (txn instanceof CreateSessionTxn) {
CreateSessionTxn cst = (CreateSessionTxn) txn;
sessionTracker.addSession(sessionId, cst
.getTimeOut());
} else {
LOG.warn("*****>>>>> Got "
+ txn.getClass() + " "
+ txn.toString());
}
} else if (opCode == OpCode.closeSession) {
sessionTracker.removeSession(sessionId);
}
return rc;
}
}
| [
"[email protected]"
]
| |
2246f2220e7b1bf6034a7c20dc01daf673b8c8a8 | 3182dd5e2cb4c93c562293816203038d5e4c9708 | /src/java/j$/util/function/A.java | 2f889805302402f252befac1bf00577fa2c46c1d | []
| no_license | mrauer/TAC-Verif | 46f1fdc06475fef6d217f48a2ee6a6ffc8ec3e4f | 5231854f94008729fb1be67992ffafd2ae8908a3 | refs/heads/master | 2023-07-16T22:25:33.181442 | 2021-08-29T16:00:37 | 2021-08-29T16:00:37 | 401,082,799 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 914 | java | /*
* Decompiled with CFR 0.0.
*
* Could not load the following classes:
* java.lang.Object
* java.util.Objects
*/
package j$.util.function;
import j$.util.function.BiConsumer;
import java.util.Objects;
public final class a
implements BiConsumer {
public final /* synthetic */ BiConsumer a;
public final /* synthetic */ BiConsumer b;
public /* synthetic */ a(BiConsumer biConsumer, BiConsumer biConsumer2) {
this.a = biConsumer;
this.b = biConsumer2;
}
@Override
public BiConsumer a(BiConsumer biConsumer) {
Objects.requireNonNull((Object)biConsumer);
return new a(this, biConsumer);
}
@Override
public final void accept(Object object, Object object2) {
BiConsumer biConsumer = this.a;
BiConsumer biConsumer2 = this.b;
biConsumer.accept(object, object2);
biConsumer2.accept(object, object2);
}
}
| [
"[email protected]"
]
| |
6b5434b0f73ab1a009e8f279e2b04b1ebeb1f289 | cbd635964da310cf1018766a6b0a3a88fd945a22 | /dayily-test/src/main/java/com/jy/leetcode/LeetCode165.java | 0d79f8f8c29afc64569a9f2d6312b8fb3f384700 | []
| no_license | WangJunT/test | 0053d773a8f76039aa1468b876dd6bdb778555d4 | 65270f78b3c8f8110a96da9fdf26b6ef51e768bf | refs/heads/master | 2023-08-22T18:32:03.596157 | 2021-10-13T07:18:46 | 2021-10-13T07:18:46 | 71,882,345 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 739 | java | package com.jy.leetcode;
public class LeetCode165 {
public static int compareVersion(String version1, String version2) {
String ver1[] = version1.split("\\.");
String ver2[] = version2.split("\\.");
int i = 0, j = 0;
for (; i < ver1.length || j < ver2.length;
i++, j++) {
int a = i < ver1.length ? Integer.valueOf(ver1[i]) : 0;
int b = j < ver2.length ? Integer.valueOf(ver1[j]) : 0;
if (a > b) {
return 1;
} else if (a < b) {
return -1;
}
}
return 0;
}
public static void main(String[] args) {
compareVersion("0.1", "1.1");
System.out.println(1);
}
}
| [
"[email protected]"
]
| |
82329f0e4cb70bc61a96d978e9f632fec790cc13 | 6411078f1b3e33a76beced33169f1c9e1893c69c | /src/main/java/com/codeoftheweb/salvo/Player.java | 484587ce1b40b02c9c7e96bda4176a2b66b53f63 | []
| no_license | roxmely/Salvo-Back-end-JAVA | d470116f26b77e27cc99edbee020f8a02ef9d542 | 549761f383662bce83ffcd8a5aa69f696b7139a6 | refs/heads/master | 2022-09-07T08:15:27.081993 | 2020-06-01T23:30:20 | 2020-06-01T23:30:20 | 267,366,466 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,037 | java | package com.codeoftheweb.salvo;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.util.*;
@Entity
public class Player {
@Id
@GeneratedValue(strategy = GenerationType.AUTO, generator = "native")
@GenericGenerator(name = "native", strategy = "native")
private Long id;
//***Descripción***//
private String email;
private String password;
@OneToMany(mappedBy = "player", fetch = FetchType.EAGER)
Set<GamePlayer> gamePlayer = new HashSet<>();//inicializar
@OneToMany(mappedBy = "player", fetch = FetchType.EAGER)
Set<Score> scores = new HashSet<>();//inicializar
//***Constructor***//
public Player() {
}
//***Personalizados***//
public Player(String email, String password) {
this.email = email;
this.password = password;
}
//***Getters-Setters***//
public Long getId() {
return id;
}
public Set<Score> getScores() {
return this.scores;
}
public String getEmail() {
return email;
}
public String getPassword() {
return password;
}
public void setEmail(String email) {
this.email = email;
}
public void setPassword(String password) {
this.password = password;
}
public void setScores(Set<Score> scores) {
this.scores = scores;
}
//***Methods***//
public void addGamePlayer(GamePlayer gamePlayer) {
gamePlayer.setPlayer(this);
this.gamePlayer.add(gamePlayer);
}
public Score scoreNull(Game game){
return scores.stream().filter(score -> score.getGame().equals(game)).findFirst().orElse(null);
}
public Map<String, Object> makePlayerDTO() {
Map<String, Object> dtoPlayer = new LinkedHashMap<String, Object>();
dtoPlayer.put("id", this.getId());
dtoPlayer.put("email", this.getEmail());
dtoPlayer.put("scores",this.getScores().stream().map(Score::getScore));
return dtoPlayer;
}
} | [
"[email protected]"
]
| |
a53275c3894694c17c4a176f38ad132977446676 | 07b44fa4d779677243409a99fbe9ae3d87876f7a | /gulimall-coupon/src/main/java/com/chen/gulimall/coupon/entity/SeckillSkuNoticeEntity.java | 84d64637a1512832eb21999d7772b151734c34b4 | [
"Apache-2.0"
]
| permissive | Randycout/gulimall | 1db58d87bae788b37b46aec5ab5f69e4d783b2af | 4bee32230ebf54137b1ac05192bb27268ef82844 | refs/heads/master | 2023-07-11T05:33:02.490624 | 2021-08-22T14:30:46 | 2021-08-22T14:30:46 | 398,820,850 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 872 | java | package com.chen.gulimall.coupon.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 秒杀商品通知订阅
*
* @author chenZhibin
* @email [email protected]
* @date 2021-06-21 21:16:51
*/
@Data
@TableName("sms_seckill_sku_notice")
public class SeckillSkuNoticeEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId
private Long id;
/**
* member_id
*/
private Long memberId;
/**
* sku_id
*/
private Long skuId;
/**
* 活动场次id
*/
private Long sessionId;
/**
* 订阅时间
*/
private Date subcribeTime;
/**
* 发送时间
*/
private Date sendTime;
/**
* 通知方式[0-短信,1-邮件]
*/
private Integer noticeType;
}
| [
"[email protected]"
]
| |
997d6dcfa599df0ee59e84d75f95be7618e45552 | b89c6c05c32a0de4c2958e0674bf9a402907db08 | /src/main/java/com/moma/framework/extra/taobao/api/internal/parser/json/ObjectJsonParser.java | ebd0aab34d5da884dab60177b274dabd5e073790 | []
| no_license | simusco/tour-guide | d11aa384528c6ee0379f99b4ce4b3500b951beee | 0d02ca51f2e7f4d2707aa57cb14dcae06ef46c6e | refs/heads/master | 2021-01-17T11:11:53.279834 | 2016-03-25T07:28:22 | 2016-03-25T07:28:22 | 42,908,609 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,068 | java | package com.moma.framework.extra.taobao.api.internal.parser.json;
import com.moma.framework.extra.taobao.api.ApiException;
import com.moma.framework.extra.taobao.api.TaobaoParser;
import com.moma.framework.extra.taobao.api.TaobaoResponse;
import com.moma.framework.extra.taobao.api.internal.mapping.Converter;
/**
* 单个JSON对象解释器。
*
* @author carver.gu
* @since 1.0, Apr 11, 2010
*/
public class ObjectJsonParser<T extends TaobaoResponse> implements TaobaoParser<T> {
private Class<T> clazz;
private boolean simplify;
public ObjectJsonParser(Class<T> clazz) {
this.clazz = clazz;
}
public ObjectJsonParser(Class<T> clazz, boolean simplify) {
this.clazz = clazz;
this.simplify = simplify;
}
public T parse(String rsp) throws ApiException {
Converter converter;
if (this.simplify) {
converter = new SimplifyJsonConverter();
} else {
converter = new JsonConverter();
}
return converter.toResponse(rsp, clazz);
}
public Class<T> getResponseClass() {
return clazz;
}
}
| [
"[email protected]"
]
| |
82bdf5ddfc4d300e4be9ec57830191e381b6d8bc | 34a5be962e2fd7855ee5f78cd2ffe40a0e47c115 | /springtest/src/main/java/com/lishiwei/springtest/FalseSharing.java | 754a8a9b3a7ac3e90039cae0572021ef1101e68a | []
| no_license | vividl/daytest | 494a9e7e8bdb4d128b12f6f6bd88cddcc1c9b148 | d10e1e105c228766833272f041e19f9db7d6bb3f | refs/heads/master | 2022-12-20T20:14:48.426218 | 2019-10-08T06:49:32 | 2019-10-08T06:49:32 | 84,549,185 | 0 | 0 | null | 2022-12-15T23:40:20 | 2017-03-10T10:37:14 | Java | UTF-8 | Java | false | false | 1,843 | java | package com.lishiwei.springtest;
public class FalseSharing implements Runnable {
public final static long ITERATIONS = 500L * 1000L * 100L;
private int arrayIndex = 0;
private static ValueNoPadding[] longs;
public FalseSharing(final int arrayIndex) {
this.arrayIndex = arrayIndex;
}
public static void main(final String[] args) throws Exception {
for (int i = 1; i < 10; i++) {
System.gc();
final long start = System.currentTimeMillis();
runTest(i);
System.out.println("Thread num " + i + " duration = " + (System.currentTimeMillis() - start));
}
}
private static void runTest(int NUM_THREADS) throws InterruptedException {
Thread[] threads = new Thread[NUM_THREADS];
longs = new ValueNoPadding[NUM_THREADS];
for (int i = 0; i < longs.length; i++) {
longs[i] = new ValueNoPadding();
}
for (int i = 0; i < threads.length; i++) {
threads[i] = new Thread(new FalseSharing(i));
}
for (Thread t : threads) {
t.start();
}
for (Thread t : threads) {
t.join();
}
System.out.println("aa");
}
public void run() {
long i = ITERATIONS + 1;
while (0 != --i) {
longs[arrayIndex].value = 0L;
}
}
//cache line
public final static class ValuePadding {
protected long p1, p2, p3, p4, p5, p6, p7;
protected volatile long value = 0L;
protected long p9, p10, p11, p12, p13, p14;
protected long p15;
}
public final static class ValueNoPadding {
protected long p1, p2, p3, p4, p5, p6, p7;
protected volatile long value = 0L;
protected long p9, p10, p11, p12, p13, p14, p15;
}
}
| [
"[email protected]"
]
| |
4c8491ca80bba4ebb105e6bbc6f5a0e12b075694 | 3277069ad7b426f18dc4769a281d7d5b84f48131 | /reports/src/test/java/jonas/emile/reports/ExampleUnitTest.java | f5991bb2ad0c58d4fd92eeffd52945f403c53814 | []
| no_license | mugbubule/citizen_android | 2b3452776d456f1b59727eb0f8770322d14f1cd1 | 1b237ac5ba06c7e1fbb34c0de24df36d30e47205 | refs/heads/master | 2021-04-03T01:56:30.644043 | 2018-11-20T16:19:29 | 2018-11-20T16:19:29 | 124,834,857 | 0 | 0 | null | 2018-11-20T16:19:31 | 2018-03-12T04:46:52 | Java | UTF-8 | Java | false | false | 397 | java | package jonas.emile.reports;
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]"
]
| |
5cd645f6c8b61f789397fc6163d7445937691e0f | 7adb3ea11858c7bea5d6dbd89d1577fa2c39c88e | /hgshop-user-service/src/main/java/com/zhanglei/hgshop/service/impl/WebUserServiceImpl.java | c59d23b5e6d8f7cd8b55988e8785a48755dc9b61 | []
| no_license | zhanglei-warehouse/hgshop-parent | 85060140611283aa4574592e3d31fe3df2c51312 | 2d1e9e6d5a1ab44491febab100b43dbfc64e7470 | refs/heads/master | 2022-12-23T07:28:58.501007 | 2020-03-12T06:53:21 | 2020-03-12T06:53:21 | 244,566,743 | 0 | 0 | null | 2022-12-15T23:58:04 | 2020-03-03T07:12:45 | CSS | UTF-8 | Java | false | false | 1,010 | java | package com.zhanglei.hgshop.service.impl;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.zhanglei.hgshop.dao.UserDao;
import com.zhanglei.hgshop.pojo.User;
import com.zhanglei.hgshop.service.WebUserService;
/**
* @ClassName: WebUserServiceIMpl
* @Description: 用户服务 商城用户
* @author: lei zhang
* @date: 2020年3月11日 下午7:44:54
*/
@Service(interfaceClass = WebUserService.class,version = "1.0.0")
public class WebUserServiceImpl implements WebUserService {
@Autowired
private UserDao userDao;
@Override
public User login(String username, String pwd) {
return userDao.find(username,DigestUtils.md5Hex(pwd));
}
@Override
public User register(User user) {
user.setPassword(DigestUtils.md5Hex(user.getPassword()));
if(userDao.add(user)>0) {
return userDao.getById(user.getUid());
}
return null;
}
}
| [
"zhanglei@DESKTOP-7TTO9GJ"
]
| zhanglei@DESKTOP-7TTO9GJ |
b60010e7eecc658c7c2b23b8c71dacc7b1523cfc | ebf931509bd13289484cf8f7b2ae35fdf65cdf82 | /HW2/src/main/java/cs455/scaling/client/ClientStatistics.java | f59b52a145944a9bf3c681fdef06becf6784dc52 | []
| no_license | avrezzon/cs455 | 3d3cc628588baf555addd143f205bb0fb624816a | aeb1dac989eec41b3652d40c14379bb45e209c1f | refs/heads/master | 2020-04-18T09:19:00.083949 | 2019-05-24T20:28:12 | 2019-05-24T20:28:12 | 167,429,844 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,072 | java | package cs455.scaling.client;
import java.util.concurrent.atomic.AtomicInteger;
public class ClientStatistics {
private AtomicInteger msgSent;
private AtomicInteger msgReceived;
private AtomicInteger mismatch;
public ClientStatistics() {
this.msgSent = new AtomicInteger(0);
this.msgReceived = new AtomicInteger(0);
this.mismatch = new AtomicInteger(0);
}
public void sentMsg() {
msgSent.getAndIncrement();
}
public void receivedMsg() {
msgReceived.getAndIncrement();
}
public void updateMismatch() {
mismatch.getAndIncrement();
}
public String toString() {
synchronized (msgSent) {
synchronized (msgReceived) {
synchronized (mismatch) {
return "[" + (System.currentTimeMillis() / 1000) + "] Total Sent Count: " + this.msgSent
+ ", Total Received Count: " + this.msgReceived
+ ", Total Bad messages received: " + this.mismatch;
}
}
}
}
}
| [
"[email protected]"
]
| |
717da56daaddaf1f21a3dae39490a289232148cf | c6ea4e7b1bd16c738be449273bc3d8d786b9215c | /Study_Web/workspace/09.Member_Board/src/com/commons/action/ActionForward.java | ca06d1b8aa2b3fb89bf37848056531b5e8c78ad4 | []
| no_license | vesteira2018/hanul_study | d1891b3db5c5dadcff05791f83d5af351818beaf | bf133d0e9b82a80232e62855add5073cde0a4660 | refs/heads/master | 2023-04-08T20:19:18.676178 | 2021-03-26T01:22:16 | 2021-03-26T01:22:16 | 351,620,703 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 483 | java | package com.commons.action;
public class ActionForward {
private String path = null; //jsp 파일의 위치(경로)와 파일명
//true : sendRedirect(), false : forward()
private boolean isRedirect = false; //페이지 전환 방식
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public boolean isRedirect() {
return isRedirect;
}
public void setRedirect(boolean isRedirect) {
this.isRedirect = isRedirect;
}
}
| [
"[email protected]"
]
| |
3e8dbcca58b250d6fe3d313d70d3b1ff7364baf0 | b1d9bd5268c826e93dcd9fb9b140e7e0c09bac8a | /src/fr/ascadis/model/Utilisateur.java | 8147778d03f6f7f671d02bd879802ba7fd075362 | []
| no_license | t-camille/BACA-tetris2 | 35e6c1dadd3fcee45422e3f9084d88ef1914fd56 | c112f7a648ab6fd91c16cec636db7462878b6ab9 | refs/heads/master | 2021-06-17T23:30:26.947286 | 2017-06-06T14:31:19 | 2017-06-06T14:31:19 | 93,521,830 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,182 | java | package fr.ascadis.model;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
import fr.ascadis.security.SecurityType;
import fr.ascadis.security.SecurityUser;
@Entity
@Table(name="utilisateur", uniqueConstraints = { @UniqueConstraint(columnNames = "UTI_USERNAME") })
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name="UTI_TYPE", discriminatorType=DiscriminatorType.INTEGER)
public abstract class Utilisateur implements Serializable, SecurityUser
{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="UTI_ID")
private int id;
@Column(name="UTI_NOM")
private String nom;
@Column(name="UTI_PRENOM")
private String prenom;
@Column(name="UTI_USERNAME")
private String username;
@Column(name="UTI_PASSWORD")
private String password;
@Column(name = "UTI_TYPE", insertable = false, updatable = false)
private int type;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public String getPrenom() {
return prenom;
}
public void setPrenom(String prenom) {
this.prenom = prenom;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getType() {
return type;
}
public SecurityType getSecurityType() {
switch (this.type) {
case 0:
return SecurityType.Administrateur;
case 1:
return SecurityType.Joueur;
default:
return SecurityType.Spectateur;
}
}
} | [
"[email protected]"
]
| |
d1dc3b79770c70244ce724d50fd77fee8845acff | 8ea8da1300c0e5a420c0526197d574b288ffcb0c | /src/main/java/org/yuesi/databridge/entity/CodeDateKey.java | 82de84896862308e16793a568d9bdce6cece20c8 | []
| no_license | YUESI/yuesi.DataBridge | ed5915094e5ff971710107ae2d61bb27cc7ff776 | 82cea621edd412ec621e6e10f5277d4012c8ccde | refs/heads/master | 2021-01-12T17:00:45.961585 | 2020-04-12T07:43:15 | 2020-04-12T07:43:15 | 71,474,601 | 2 | 2 | null | null | null | null | UTF-8 | Java | false | false | 616 | java | package org.yuesi.databridge.entity;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Embeddable;
@Embeddable
public class CodeDateKey implements Serializable {
/**
*
*/
private static final long serialVersionUID = -3011087291369227690L;
@Column(name="code", columnDefinition = "varchar(12)")
private String code;
@Column(name="tradedate", columnDefinition = "date")
private Date tradeDate;
// 省略setter,getter方法
@Override
public String toString() {
return "CodeDateKey [code=" + code + ", tradedate=" + tradeDate + "]";
}
}
| [
"[email protected]"
]
| |
4fbf70831ec60dd231b85e1a899a370d0ce35a5f | ab6788fafd20909db806ffa2f2b3f5d811037594 | /youshoes/src/shoes/dto/pmDTO.java | b5e434fac15666e23a8a76c78b8446e02ce63c32 | []
| no_license | GyodongGu/youshoes2 | d171f6362ecea72f66e9ca721013fcdf93f635eb | eb99a937a92c64049aab66f892ee115659a769da | refs/heads/master | 2022-12-09T07:00:39.167893 | 2020-04-02T08:13:05 | 2020-04-02T08:13:05 | 252,393,977 | 0 | 0 | null | 2022-12-05T17:49:48 | 2020-04-02T08:09:45 | JavaScript | UTF-8 | Java | false | false | 2,462 | java | package shoes.dto;
import java.sql.Date;
public class pmDTO {
private int pm_no;
private String pm_id;
private String pm_pw;
private String pm_name;
private String pm_stat_cd;
private Date pm_birth;
private String pm_email;
private Date pm_date;
private String pm_tell;
private String pm_post;
private String pm_addr1;
private String pm_addr2;
private String pm_addr3;
private int point_now;
private String mgr_auth_cd;
private String img_name;
public String getImg_name() {
return img_name;
}
public void setImg_name(String img_name) {
this.img_name = img_name;
}
public String getMgr_auth_cd() {
return mgr_auth_cd;
}
public void setMgr_auth_cd(String mgr_auth_cd) {
this.mgr_auth_cd = mgr_auth_cd;
}
public int getPm_no() {
return pm_no;
}
public void setPm_no(int pm_no) {
this.pm_no = pm_no;
}
public String getPm_id() {
return pm_id;
}
public void setPm_id(String pm_id) {
this.pm_id = pm_id;
}
public String getPm_pw() {
return pm_pw;
}
public void setPm_pw(String pm_pw) {
this.pm_pw = pm_pw;
}
public String getPm_name() {
return pm_name;
}
public void setPm_name(String pm_name) {
this.pm_name = pm_name;
}
public String getPm_stat_cd() {
return pm_stat_cd;
}
public void setPm_stat_cd(String pm_stat_cd) {
this.pm_stat_cd = pm_stat_cd;
}
public Date getPm_birth() {
return pm_birth;
}
public void setPm_birth(Date pm_birth) {
this.pm_birth = pm_birth;
}
public String getPm_email() {
return pm_email;
}
public void setPm_email(String pm_email) {
this.pm_email = pm_email;
}
public Date getPm_date() {
return pm_date;
}
public void setPm_date(Date pm_date) {
this.pm_date = pm_date;
}
public String getPm_tell() {
return pm_tell;
}
public void setPm_tell(String pm_tell) {
this.pm_tell = pm_tell;
}
public String getPm_post() {
return pm_post;
}
public void setPm_post(String pm_post) {
this.pm_post = pm_post;
}
public String getPm_addr1() {
return pm_addr1;
}
public void setPm_addr1(String pm_addr1) {
this.pm_addr1 = pm_addr1;
}
public String getPm_addr2() {
return pm_addr2;
}
public void setPm_addr2(String pm_addr2) {
this.pm_addr2 = pm_addr2;
}
public String getPm_addr3() {
return pm_addr3;
}
public void setPm_addr3(String pm_addr3) {
this.pm_addr3 = pm_addr3;
}
public int getPoint_now() {
return point_now;
}
public void setPoint_now(int point_now) {
this.point_now = point_now;
}
}
| [
"user@YD03-16"
]
| user@YD03-16 |
bd875fc1651cbf03bf9e9e354388c4fef6daca1d | 6e3ab0d677d0c60351780b67936cabecd882f4ff | /src/main/java/com/kripesh/cms/model/Person.java | 3ad38d32c4c26081cdf6cccce7c2ed029ef4c3eb | []
| no_license | kripesh123/spring-boot-application | 184e3812e3f6fa95f915151031713deefad5c4a7 | d530c3cfe75103daee9d434bae90b8be6bef8c78 | refs/heads/master | 2023-01-06T21:59:30.491455 | 2020-10-15T03:15:25 | 2020-10-15T03:15:25 | 303,034,424 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 322 | java | package com.kripesh.cms.model;
public class Person {
private final long id;
private final String name;
public Person(long id, String name){
this.id = id;
this.name = name;
}
public long getId(){
return id;
}
public String getName(){
return name;
}
}
| [
"[email protected]"
]
| |
016a62e622b59387d53f566e7c90cc107d7e671a | 8c2ee81fc94f17f1d1ab888a82253a0275dd3ca2 | /movies-api/src/main/java/com/mycompany/moviesapi/rest/dto/MovieResponse.java | bbdd8f069f00052482817032b4e04b41915dda4d | []
| no_license | AlexRogalskiy/springboot-elk-prometheus-grafana | 8da0b90ce17e2b80809ddf03397b7ed01d54979d | f6ae18cf6f3c488d7a775588b2581818ee2e7125 | refs/heads/master | 2023-08-30T21:19:18.077796 | 2021-09-14T13:25:31 | 2021-09-14T13:25:31 | 415,878,653 | 0 | 0 | null | 2021-10-11T10:30:33 | 2021-10-11T10:30:17 | null | UTF-8 | Java | false | false | 193 | java | package com.mycompany.moviesapi.rest.dto;
import lombok.Value;
@Value
public class MovieResponse {
String imdb;
String title;
Short year;
String genre;
String country;
}
| [
"[email protected]"
]
| |
bc6cdd63eb0c683c0ee2655d0f0ace1f96754597 | 981f4a83129eb571d1b727714cad11e761b0153c | /es-helper-base/src/main/java/com/zheng/es/model/EsSearchResponse.java | a6c4ef139b984a35200c983d5258a520da032189 | []
| no_license | zl736732419/es-helper | d842d1ce4d6f9793a7595bd1124b3a997815a994 | 9c3ca4844a68bc0d4dd086ebe63dc2446bcb8c0d | refs/heads/master | 2020-04-29T06:58:10.962562 | 2019-04-30T10:22:29 | 2019-04-30T10:22:29 | 175,936,745 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,801 | java | package com.zheng.es.model;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.aggregations.Aggregations;
import java.util.Objects;
/**
* <pre>
*
* File:
*
* Copyright (c) 2016, globalegrow.com All Rights Reserved.
*
* Description:
* es响应结果
*
* Revision History
* Date, Who, What;
* 2019年04月12日 zhenglian Initial.
*
* </pre>
*/
public class EsSearchResponse {
/**
* 请求状态
*/
private RestStatus status;
/**
* 请求耗费时间
*/
private TimeValue took;
/**
* 查询结果
*/
private SearchHits searchHits;
/**
* 聚合结果
*/
private Aggregations aggregations;
/**
* 滚动查询id
*/
private String scrollId;
private EsSearchResponse() {}
public RestStatus getStatus() {
return status;
}
public void setStatus(RestStatus status) {
this.status = status;
}
public TimeValue getTook() {
return took;
}
public void setTook(TimeValue took) {
this.took = took;
}
public SearchHits getSearchHits() {
return searchHits;
}
public void setSearchHits(SearchHits searchHits) {
this.searchHits = searchHits;
}
public Aggregations getAggregations() {
return aggregations;
}
public void setAggregations(Aggregations aggregations) {
this.aggregations = aggregations;
}
public String getScrollId() {
return scrollId;
}
public void setScrollId(String scrollId) {
this.scrollId = scrollId;
}
public boolean isSuccess() {
return Objects.equals(status.getStatus(), RestStatus.OK.getStatus());
}
public static class Builder {
private EsSearchResponse response;
public Builder() {
response = new EsSearchResponse();
}
public Builder status(RestStatus status) {
response.status = status;
return this;
}
public Builder took(TimeValue took) {
response.took = took;
return this;
}
public Builder searchHits(SearchHits searchHits) {
response.searchHits = searchHits;
return this;
}
public Builder aggregations(Aggregations aggregations) {
response.aggregations = aggregations;
return this;
}
public Builder scrollId(String scrollId) {
response.scrollId = scrollId;
return this;
}
public EsSearchResponse build() {
return response;
}
}
}
| [
"[email protected]"
]
| |
8c4ba6090bd91a20ad085f95760f76187f9631ee | 5bd2833cb603ae6d714adc0a8521e6c755b0f8e5 | /Exercicio02-Design Patterns/src/br/com/fiap/jpa/entity/Corrida.java | 4bf9f80a60ddbd6d584d41606500fc7cbc44b205 | []
| no_license | viniciusnicolaus/Enterprise-Application-Development | 3a80a85e1f05cd01a488861d7e1be03c2c1157d3 | 30b356e8492bca6bdbd370d88251eeda886078d8 | refs/heads/master | 2020-03-25T16:33:58.961281 | 2018-08-07T23:37:26 | 2018-08-07T23:37:26 | 122,187,432 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,835 | java | package br.com.fiap.jpa.entity;
import java.util.Calendar;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name="T_CORRIDA")
@SequenceGenerator(name="corrida", sequenceName="SQ_T_CORRIDA", allocationSize=1)
public class Corrida {
@Id
@Column(name="cd_corrida")
@GeneratedValue(generator="corrida", strategy=GenerationType.SEQUENCE)
private int codigoCorrida;
@Column(name="ds_origem", length=150)
private String origem;
@Column(name="ds_destino", length=150)
private String destino;
@Temporal(TemporalType.DATE)
@Column(name="dt_corrida")
private Calendar dataCorrida;
@Column(name="vl_corrida", nullable=false)
private float valor;
public Corrida() {
}
public Corrida(String origem, String destino, Calendar dataCorrida, float valor) {
super();
this.origem = origem;
this.destino = destino;
this.dataCorrida = dataCorrida;
this.valor = valor;
}
public int getCodigoCorrida() {
return codigoCorrida;
}
public void setCodigoCorrida(int codigoCorrida) {
this.codigoCorrida = codigoCorrida;
}
public String getOrigem() {
return origem;
}
public void setOrigem(String origem) {
this.origem = origem;
}
public String getDestino() {
return destino;
}
public void setDestino(String destino) {
this.destino = destino;
}
public Calendar getDataCorrida() {
return dataCorrida;
}
public void setDataCorrida(Calendar dataCorrida) {
this.dataCorrida = dataCorrida;
}
public float getValor() {
return valor;
}
public void setValor(float valor) {
this.valor = valor;
}
}
| [
"[email protected]"
]
| |
74869f12afd49b1f5bb96084e66e6f529f450024 | 48cc0591cbe8fd5003b76d9722b7d987f4287cf5 | /[email protected]:topdeveloperRay/gamehome.git/gamehome/src/main/java/com/dr/galaxy/gamehome/service/CircleService.java | 6e6639f6f99d44f4d20f7118a546de9edd7f4014 | []
| no_license | taofuyu/gamehome | a9910f0702f71f52eef4995a494a6afeb4d17a8e | 435d69561d7b9b7055a2c11d937f8aafa0437fa9 | refs/heads/master | 2020-05-05T02:08:59.264071 | 2017-07-30T14:55:48 | 2017-07-30T14:55:48 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 882 | java | package com.dr.galaxy.gamehome.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dr.galaxy.gamehome.model.Circle;
import com.dr.galaxy.gamehome.repository.CircleRepository;
@Service
public class CircleService {
@Autowired
private CircleRepository circleRepository;
public Iterable<Circle> getAllCircles() {
return circleRepository.findAll();
}
public Circle getCircleById(String circleId) {
return circleRepository.findOne(circleId);
}
public Circle saveCircle(final Circle circle) {
if (circleRepository.findOne(circle.getCircleId()) == null) {
return circleRepository.save(circle);
} else {
deleteCircleById(circle.getCircleId());
return circleRepository.save(circle);
}
}
public void deleteCircleById(String circleId) {
circleRepository.delete(circleId);
}
}
| [
"[email protected]"
]
| |
f2bb4a3f7c68b0fbca73289d149b6f4eedd5323d | 7b0521dfb4ec76ee1632b614f32ee532f4626ea2 | /src/main/java/alcoholmod/Mathioks/CommandChangeStats.java | dea888a6c52eb429cf4a5db387adc972470cb08d | []
| no_license | M9wo/NarutoUnderworld | 6c5be180ab3a00b4664fd74f6305e7a1b50fe9fc | 948065d8d43b0020443c0020775991b91f01dd50 | refs/heads/master | 2023-06-29T09:27:24.629868 | 2021-07-27T03:18:08 | 2021-07-27T03:18:08 | 389,832,397 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,935 | java | package alcoholmod.Mathioks;
import alcoholmod.Mathioks.ExtraFunctions.SyncKinjutsuMessage;
import alcoholmod.Mathioks.ExtraFunctions.SyncSenjutsuMessage;
import alcoholmod.Mathioks.ExtraFunctions.SyncSkillPointsMessage;
import alcoholmod.Mathioks.TransformationsRealPackage.SyncHealthMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import java.util.List;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.command.WrongUsageException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
public class CommandChangeStats extends CommandBase {
boolean isInteger(String s) {
try {
Integer.parseInt(s);
return true;
} catch (NumberFormatException var3) {
return false;
}
}
public int getRequiredPermissionLevel() {
return 2;
}
public String getCommandName() {
return "changestats";
}
public String getCommandUsage(ICommandSender sender) {
return "/changestats <STAT> <add/set> <AMOUNT> <PLAYER>";
}
public void processCommand(ICommandSender sender, String[] args) {
if (args.length == 4) {
new NBTTagCompound();
EntityPlayerMP entityplayermp = getPlayer(sender, args[3]);
ExtendedPlayer props = ExtendedPlayer.get((EntityPlayer)entityplayermp);
if (args[0].equals("Medical")) {
if (args[1].equals("add") && isInteger(args[2]))
if (Integer.valueOf(args[2]).intValue() + props.getHealth() <= 500) {
props.setHealth(props.getHealth() + Integer.valueOf(args[2]).intValue());
PacketDispatcher.sendTo((IMessage)new SyncHealthMessage((EntityPlayer)entityplayermp), entityplayermp);
sender.addChatMessage((IChatComponent)new ChatComponentText("Given " + args[2] + " points in " + args[0] + " to " + entityplayermp.getDisplayName() + "."));
} else {
int result1 = Integer.valueOf(args[2]).intValue() - Math.abs(500 - props.getHealth() + Integer.valueOf(args[2]).intValue());
int result2 = Math.abs(500 - props.getHealth() + Integer.valueOf(args[2]).intValue());
props.setHealth(props.getHealth() + result1);
PacketDispatcher.sendTo((IMessage)new SyncHealthMessage((EntityPlayer)entityplayermp), entityplayermp);
props.setSkillPoints(props.getSkillPoints() + result2);
PacketDispatcher.sendTo((IMessage)new SyncSkillPointsMessage((EntityPlayer)entityplayermp), entityplayermp);
sender.addChatMessage((IChatComponent)new ChatComponentText("Given " + result1 + " " + args[0] + " points and " + result2 + " Skill Points to " + entityplayermp.getDisplayName() + "."));
}
if (args[1].equals("set") && isInteger(args[2]) && Integer.valueOf(args[2]).intValue() <= 500) {
props.setHealth(Integer.valueOf(args[2]).intValue());
PacketDispatcher.sendTo((IMessage)new SyncHealthMessage((EntityPlayer)entityplayermp), entityplayermp);
sender.addChatMessage((IChatComponent)new ChatComponentText("Setting " + entityplayermp.getDisplayName() + "'s points in " + args[0] + " to " + args[2] + "."));
}
}
if (args[0].equals("Kinjutsu")) {
if (args[1].equals("add") && isInteger(args[2]))
if (Integer.valueOf(args[2]).intValue() + props.getKinjutsu() <= 100) {
props.setKinjutsu(props.getKinjutsu() + Integer.valueOf(args[2]).intValue());
PacketDispatcher.sendTo((IMessage)new SyncKinjutsuMessage((EntityPlayer)entityplayermp), entityplayermp);
sender.addChatMessage((IChatComponent)new ChatComponentText("Given " + args[2] + " points in " + args[0] + " to " + entityplayermp.getDisplayName() + "."));
} else {
int result1 = Integer.valueOf(args[2]).intValue() - Math.abs(100 - props.getKinjutsu() + Integer.valueOf(args[2]).intValue());
int result2 = Math.abs(100 - props.getKinjutsu() + Integer.valueOf(args[2]).intValue());
props.setKinjutsu(props.getKinjutsu() + result1);
PacketDispatcher.sendTo((IMessage)new SyncKinjutsuMessage((EntityPlayer)entityplayermp), entityplayermp);
props.setSkillPoints(props.getSkillPoints() + result2);
PacketDispatcher.sendTo((IMessage)new SyncSkillPointsMessage((EntityPlayer)entityplayermp), entityplayermp);
sender.addChatMessage((IChatComponent)new ChatComponentText("Given " + result1 + " " + args[0] + " points and " + result2 + " Skill Points to " + entityplayermp.getDisplayName() + "."));
}
if (args[1].equals("set") && isInteger(args[2]) && Integer.valueOf(args[2]).intValue() <= 100) {
props.setKinjutsu(Integer.valueOf(args[2]).intValue());
PacketDispatcher.sendTo((IMessage)new SyncKinjutsuMessage((EntityPlayer)entityplayermp), entityplayermp);
sender.addChatMessage((IChatComponent)new ChatComponentText("Setting " + entityplayermp.getDisplayName() + "'s points in " + args[0] + " to " + args[2] + "."));
}
}
if (args[0].equals("Senjutsu")) {
if (args[1].equals("add") && isInteger(args[2]))
if (Integer.valueOf(args[2]).intValue() * 5 + props.getSenjutsu() <= 3000) {
props.setSenjutsu(props.getSenjutsu() + Integer.valueOf(args[2]).intValue() * 5);
PacketDispatcher.sendTo((IMessage)new SyncSenjutsuMessage((EntityPlayer)entityplayermp), entityplayermp);
sender.addChatMessage((IChatComponent)new ChatComponentText("Given " + args[2] + " points in " + args[0] + " to " + entityplayermp.getDisplayName() + "."));
} else {
int result1 = Integer.valueOf(args[2]).intValue() * 5 - Math.abs(3000 - props.getSenjutsu() + Integer.valueOf(args[2]).intValue() * 5);
props.setSenjutsu(props.getSenjutsu() + result1);
PacketDispatcher.sendTo((IMessage)new SyncSenjutsuMessage((EntityPlayer)entityplayermp), entityplayermp);
sender.addChatMessage((IChatComponent)new ChatComponentText("Given " + result1 + " " + args[0] + " points to " + entityplayermp.getDisplayName() + "."));
}
if (args[1].equals("set") && isInteger(args[2]) && Integer.valueOf(args[2]).intValue() * 5 <= 3000) {
props.setSenjutsu(Integer.valueOf(args[2]).intValue() * 5);
PacketDispatcher.sendTo((IMessage)new SyncSenjutsuMessage((EntityPlayer)entityplayermp), entityplayermp);
sender.addChatMessage((IChatComponent)new ChatComponentText("Setting " + entityplayermp.getDisplayName() + "'s points in " + args[0] + " to " + args[2] + "."));
}
}
if (args[0].equals("Ninjutsu")) {
if (args[1].equals("add") && isInteger(args[2])) {
props.setNinjutsu(props.getNinjutsu() + Integer.valueOf(args[2]).intValue());
PacketDispatcher.sendTo((IMessage)new SyncSenjutsuMessage((EntityPlayer)entityplayermp), entityplayermp);
sender.addChatMessage((IChatComponent)new ChatComponentText("Given " + args[2] + " points in " + args[0] + " to " + entityplayermp.getDisplayName() + "."));
}
if (args[1].equals("set") && isInteger(args[2])) {
props.setNinjutsu(Integer.valueOf(args[2]).intValue());
PacketDispatcher.sendTo((IMessage)new SyncSenjutsuMessage((EntityPlayer)entityplayermp), entityplayermp);
sender.addChatMessage((IChatComponent)new ChatComponentText("Setting " + entityplayermp.getDisplayName() + "'s points in " + args[0] + " to " + args[2] + "."));
}
}
if (args[0].equals("Intelligence")) {
if (args[1].equals("add") && isInteger(args[2]))
if (Integer.valueOf(args[2]).intValue() + props.getIntelligence() <= 100) {
props.setIntelligence(props.getIntelligence() + Integer.valueOf(args[2]).intValue());
PacketDispatcher.sendTo((IMessage)new SyncSenjutsuMessage((EntityPlayer)entityplayermp), entityplayermp);
sender.addChatMessage((IChatComponent)new ChatComponentText("Given " + args[2] + " points in " + args[0] + " to " + entityplayermp.getDisplayName() + "."));
} else {
int result1 = 100 - props.getIntelligence();
props.setIntelligence(props.getIntelligence() + result1);
PacketDispatcher.sendTo((IMessage)new SyncSenjutsuMessage((EntityPlayer)entityplayermp), entityplayermp);
sender.addChatMessage((IChatComponent)new ChatComponentText("Given " + result1 + " " + args[0] + " points to " + entityplayermp.getDisplayName() + "."));
}
if (args[1].equals("set") && isInteger(args[2]) && Integer.valueOf(args[2]).intValue() <= 100) {
props.setIntelligence(Integer.valueOf(args[2]).intValue());
PacketDispatcher.sendTo((IMessage)new SyncSenjutsuMessage((EntityPlayer)entityplayermp), entityplayermp);
sender.addChatMessage((IChatComponent)new ChatComponentText("Setting " + entityplayermp.getDisplayName() + "'s points in " + args[0] + " to " + args[2] + "."));
}
}
} else {
throw new WrongUsageException("Too many or not enough arguments. Usage: /changestats <STAT> <add/set> <AMOUNT> <PLAYER>", new Object[0]);
}
}
public List addTabCompletionOptions(ICommandSender sender, String[] args) {
return (args.length == 1) ? getListOfStringsMatchingLastWord(args, new String[] { "Medical", "Kinjutsu", "Senjutsu", "Ninjutsu", "Intelligence" }) : ((args.length == 2) ? getListOfStringsMatchingLastWord(args, new String[] { "add", "set" }) : ((args.length == 5) ? getListOfStringsMatchingLastWord(args, getPlayers()) : null));
}
public String[] getPlayers() {
return MinecraftServer.getServer().getAllUsernames();
}
}
| [
"[email protected]"
]
| |
1470302f6b1db5ad39459494ef1e9dc4a9d743d3 | b5fd02e73ec021e564e5278acb944631528de1eb | /IRCTCMadeEasy/app/src/main/java/irctc/factor/app/irctcmadeeasy/Utils/StationDetails.java | 78605a598bef68c540ca71f5a60b5e1bf1ea9808 | []
| no_license | hsadhamh/irctc_app | 83abcd418bf440d406e4e80daf949d2d73226a6b | 8856b1ff042f6622571f3fa6b92f8ebdd99b6f6d | refs/heads/master | 2020-07-09T00:34:43.627454 | 2016-10-02T15:43:57 | 2016-10-02T15:43:57 | 203,822,925 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 458 | java | package irctc.factor.app.irctcmadeeasy.Utils;
/**
* Created by hassanhussain on 8/23/2016.
*/
public class StationDetails implements Comparable<StationDetails>{
public String StationCode, StationName, StationFullName;
@Override
public int compareTo(StationDetails another) {
return this.StationCode.compareToIgnoreCase(another.StationName.toLowerCase());
}
@Override
public String toString(){ return StationFullName; }
}
| [
"[email protected]"
]
| |
b9196ee4411376664390437b4a06c3a03bf61569 | 2f0841b6ee1498af0f88dad3d9279b1b53a47d25 | /MovieReviewsRestService/src/main/java/open/source/moviereviews/service/MovieReviewServiceImpl.java | 35d613a71e34e9d036355a48a623ee800ba36636 | []
| no_license | shahzebK/Spring-Samples | 7114b47a4107667bcde014d100cf35258ce41018 | 3d9e713d39776af21926ee2a9187849732a0c24e | refs/heads/master | 2021-01-18T04:25:50.053907 | 2015-04-16T23:26:47 | 2015-04-16T23:26:47 | 37,445,877 | 1 | 0 | null | 2015-06-15T05:43:28 | 2015-06-15T05:43:27 | null | UTF-8 | Java | false | false | 2,747 | java | package open.source.moviereviews.service;
import open.source.moviereviews.domain.MovieDTO;
import open.source.moviereviews.domain.ReviewDTO;
import open.source.moviereviews.persistence.model.Movie;
import open.source.moviereviews.persistence.model.Review;
import open.source.moviereviews.persistence.model.User;
import open.source.moviereviews.persistence.repos.ReviewRepository;
import open.source.moviereviews.persistence.repos.MovieRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collection;
@Service
public class MovieReviewServiceImpl implements MovieReviewService {
@Autowired
private MovieRepository movieRepository;
@Autowired
private ReviewRepository reviewRepository;
@Override
public MovieDTO submitMovie(MovieDTO movie, User user) throws DataAccessException {
Movie modelMovie = new Movie();
modelMovie.setId(null);
modelMovie.setCreatedBy(user);
modelMovie.setMovieName(movie.getMovieName());
modelMovie.setMovieDescription(movie.getMovieDescription());
modelMovie = movieRepository.save(modelMovie);
movie.setId(modelMovie.getId());
return movie;
}
@Override
public MovieDTO editMovie(MovieDTO movie, User user) throws DataAccessException {
Movie persistedMovie = movieRepository.findOne(movie.getId());
if(persistedMovie != null && persistedMovie.getCreatedBy().equals(user)) {
persistedMovie.setMovieName(movie.getMovieName());
persistedMovie.setMovieDescription(movie.getMovieDescription());
persistedMovie = movieRepository.save(persistedMovie);
return movie;
} else {
throw new RuntimeException("Unauthorised");
}
}
@Override
public MovieDTO submitReview(ReviewDTO review, User user) throws DataAccessException {
Movie persistedMovie = movieRepository.findOne(review.getMovieId());
Review modelReview = new Review();
modelReview.setId(null);
modelReview.setCreatedBy(user);
modelReview.setReview(review.getReview());
modelReview.setMovie(persistedMovie);
persistedMovie.addReview(modelReview);
persistedMovie = movieRepository.save(persistedMovie);
return persistedMovie.toDTO();
}
@Override
public Collection<MovieDTO> getAllMovies() throws DataAccessException {
Collection<MovieDTO> movies = new ArrayList<MovieDTO>();
Collection<Movie> persistedMovies = movieRepository.findAll();
for(Movie persistedMovie : persistedMovies) {
movies.add(persistedMovie.toDTO());
}
return movies;
}
@Override
public MovieDTO getMovie(Long id) throws DataAccessException {
Movie movie = movieRepository.findById(id);
return movie == null ? null : movie.toDTO();
}
}
| [
"[email protected]"
]
| |
2c45ad5624dc0f032fd6dacec4eef7613606c146 | 430f0f6fcd13a1c2e63857f095900e4b10a654a2 | /TimeReport/src/org/qris/timereport/ActivityEditor.java | 9067a883364aa5105cbf8a61d039661799623f05 | []
| no_license | mvturnho/TimeReport | 5027dba9aede4028aba7f1e12d9b0ad9031265ed | df908302095058b7250c99b80022f381d9941874 | refs/heads/master | 2021-03-12T22:18:33.673283 | 2012-08-01T08:30:39 | 2012-08-01T08:30:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,801 | java | /**
*
*/
package org.qris.timereport;
import org.qris.timereport.R;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;
/**
* @author MVTURNHO
*
*/
public class ActivityEditor extends Activity {
private int mIDIndex;
private int mActivityIndex;
private int mNumIndex;
private int mStatusIndex;
private boolean mDirty = false;
private String mAction;
private Uri mUri;
private Cursor mCursor = null;
private EditText mActivityText;
private EditText mActivityNrText;
private CheckBox mStatusCheckBox;
private EditText mRateText;
private Button mDeleteButton;
private Button mSaveButton;
private Button mCancelButton;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activityedit);
final Intent intent = getIntent();
mAction = intent.getAction();
mUri = intent.getData();
if (!mAction.matches("Add")) {
mCursor = managedQuery(mUri, Constants.FROM_ACTIVITY_PROJECTION,
null, null, null);
mIDIndex = mCursor.getColumnIndex(android.provider.BaseColumns._ID);
mActivityIndex = mCursor.getColumnIndex(Constants.ACTIVITY);
mNumIndex = mCursor.getColumnIndex(Constants.ACTIVITY_NR);
mStatusIndex = mCursor.getColumnIndex(Constants.STATUS);
}
mDeleteButton = (Button) this.findViewById(R.id.button_delete);
mDeleteButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDirty = false;
Uri uri = getIntent().getData();
getContentResolver().delete(uri, null, null);
finish();
}
});
mSaveButton = (Button) this.findViewById(R.id.button_save);
mSaveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDirty = true;
finish();
}
});
mCancelButton = (Button) this.findViewById(R.id.button_cancel);
mCancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mDirty = false;
finish();
}
});
mActivityText = (EditText) findViewById(R.id.item_activity);
mActivityNrText = (EditText) findViewById(R.id.item_num);
mStatusCheckBox = (CheckBox) findViewById(R.id.item_status);
mDeleteButton.setVisibility(Button.INVISIBLE);
}
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
if (mDirty)
saveRecord();
}
private void saveRecord() {
ContentValues values = new ContentValues();
values.put(Constants.ACTIVITY, mActivityText.getText().toString());
values.put(Constants.ACTIVITY_NR, mActivityNrText.getText().toString());
values.put(Constants.STATUS, mStatusCheckBox.isChecked());
if (!mAction.matches("Add"))
getContentResolver().update(mUri, values, null, null);
else
getContentResolver().insert(mUri, values);
}
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
if (mCursor != null) {
// Make sure we are at the one and only row in the cursor.
mCursor.moveToFirst();
mActivityText.setText(mCursor.getString(mActivityIndex));
mActivityNrText.setText(mCursor.getString(mNumIndex));
mStatusCheckBox.setChecked(mCursor.getInt(mStatusIndex) != 0);
// mActivityNrText.setText(mCursor.getString(mNumIndex));
mDeleteButton.setVisibility(Button.VISIBLE);
} else {
;
}
}
}
| [
"[email protected]"
]
| |
ea79c444b347eb54b87b70dd006fc8dbff3072ca | b78646cbf7a7f58918d4486ec805e2b04f6cc602 | /app/src/main/java/com/eex/mvp/assrtsjava/activity/TransferActivity.java | d7fd06039cd48083c9670559e3d007b8a088c83c | []
| no_license | qingyuyefeng/eex | 3944df80bd7b22e3891fc0d7669ed0a473df55d9 | 3b1df7705b6e35d1ee62d4801d38fdc83d3e970d | refs/heads/master | 2020-12-15T07:52:33.399946 | 2020-01-20T09:23:36 | 2020-01-20T09:23:36 | 235,034,114 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,951 | java | package com.eex.mvp.assrtsjava.activity;
import android.annotation.SuppressLint;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.eex.R;
import com.eex.assets.bean.CtcaccountList;
import com.eex.common.api.ApiFactory;
import com.eex.common.api.RxSchedulers;
import com.eex.common.base.BaseActivity;
import com.eex.common.view.NewComTitleBar;
import com.eex.extensions.RxExtensionKt;
import com.eex.mvp.assrtsjava.adapter.TransferAdapter;
import java.util.ArrayList;
import java.util.HashMap;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
/**
* _ooOoo_
* o8888888o
* 88" . "88
* (| -_- |)
* O\ = /O
* ____/`---'\____
* . ' \\| |// `.
* / \\||| : |||// \
* / _||||| -:- |||||- \
* | | \\\ - /// | |
* | \_| ''\---/'' | |
* \ .-\__ `-` ___/-. /
* ___`. .' /--.--\ `. . __
* ."" '< `.___\_<|>_/___.' >'"".
* | | : `- \`.;`\ _ /`;.`/ - ` : | |
* \ \ `-. \_ __\ /__ _/ .-` / /
* ======`-.____`-.___\_____/___.-`____.-'======
* `=---='
* <p>
* .............................................
* 佛祖保佑 永无BUG
*
* @ProjectName: overthrow
* @Package: com.overthrow.mvp.assrtsjava.activity
* @ClassName: TransferActivity
* @Description: 划转
* @Author: hcj
* @CreateDate: 2019/12/25 13:32
* @UpdateUser: 更新者
* @UpdateDate: 2019/12/25 13:32
* @UpdateRemark: 更新说明
* @Version: 1.0
*/
public class TransferActivity extends BaseActivity implements BaseQuickAdapter.OnItemClickListener {
@BindView(R.id.Chargebar)
NewComTitleBar Chargebar;
@BindView(R.id.search_edit)
EditText searchEdit;
@BindView(R.id.search_back)
TextView searchBack;
@BindView(R.id.recyclerView)
RecyclerView recyclerView;
@BindView(R.id.AssetsChargeMoney)
LinearLayout AssetsChargeMoney;
private ArrayList<CtcaccountList> list = new ArrayList<>();
private ArrayList<CtcaccountList> mNewList = new ArrayList<>();
private TransferAdapter adapter;
@Override
protected int getLayoutId() {
return R.layout.re_activity_assets_charge_money;
}
@Override
protected void refreshData(Bundle savedInstanceState) {
Chargebar.setTitle(getActivity().getResources().getString(R.string.Currency_choice));
init();
net();
}
private void init() {
searchEdit.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (!searchEdit.getText().toString().trim().equals("")) {
if (list == null || list.size() == 0) {
Toast.makeText(getApplicationContext(), "", Toast.LENGTH_SHORT).show();
} else {
mNewList.clear();
String sq = searchEdit.getText().toString().trim();
for (int i = 0; i < list.size(); i++) {
if (list.get(i).getCoinCode().contains(sq.toUpperCase())) {
mNewList.add(list.get(i));
}
setView();
}
}
} else {
mNewList = new ArrayList<CtcaccountList>();
mNewList.clear();
setView();
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
private void setView() {
adapter = new TransferAdapter(list);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(adapter);
adapter.setOnItemClickListener(this);
adapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
intent.putExtra("coinCode", list.get(position).getCoinCode());
intent.putExtra("UsableMoney", list.get(position).getUsableMoney().stripTrailingZeros().toPlainString());
intent.setClass(getActivity(), AssetsChargeMoneActivity.class);
startActivity(intent);
}
});
}
@SuppressLint("CheckResult")
private void net() {
// HashMap<String, String> hashMap = new HashMap<>();
// ApiFactory.getInstance()
// .accountinfo(kv.decodeString("tokenId"), hashMap)
// .compose(RxSchedulers.io_main())
// .subscribe(data -> {
// if (data.getData() != null) {
// Log.e("null", "net: " + data.getData().toString());
//
// list.clear();
// list.addAll(data.getData().getUserCoinAccount());
// adapter.notifyDataSetChanged();
//
//
// } else {
// t(data.getMsg());
// }
//
// }, throwable -> {
//
// Log.e("TAG", "net: " + throwable.toString());
//
// });
HashMap<String, String> hashMap = new HashMap<>();
final ProgressDialog dialog = ProgressDialog.show(getActivity(), "提示", "正在加载中...");
RxExtensionKt.filterResult(ApiFactory.getInstance()
.listctcaccount(kv.decodeString("tokenId"), hashMap))
.compose(RxSchedulers.io_main())
.subscribe(ctcaccountData -> {
dialog.dismiss();
if (ctcaccountData.getData() != null) {
list.clear();
list.addAll(ctcaccountData.getData().getList());
adapter.notifyDataSetChanged();
} else {
t(ctcaccountData.getMsg());
}
}, throwable -> {
dialog.dismiss();
});
}
@Override
protected void initUiAndListener() {
adapter = new TransferAdapter(list);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(adapter);
adapter.setOnItemClickListener(this);
}
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
intent.putExtra("coinCode", list.get(position).getCoinCode());
intent.putExtra("UsableMoney", list.get(position).getUsableMoney().stripTrailingZeros().toPlainString());
intent.setClass(getActivity(), AssetsChargeMoneActivity.class);
startActivity(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// TODO: add setContentView(...) invocation
ButterKnife.bind(this);
}
@OnClick({R.id.Chargebar, R.id.search_edit, R.id.search_back, R.id.recyclerView, R.id.AssetsChargeMoney})
public void onClick(View view) {
switch (view.getId()) {
case R.id.Chargebar:
finish();
break;
case R.id.search_edit:
net();
break;
case R.id.search_back:
finish();
break;
case R.id.recyclerView:
break;
case R.id.AssetsChargeMoney:
break;
}
}
}
| [
"[email protected]"
]
| |
7d258a33c67f75c2cc50aad7ebaf76c66de2f0a6 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/20/20_51f6d0b34b9752eba0754155050ac4945f80cc3d/GroupAssertionsTest/20_51f6d0b34b9752eba0754155050ac4945f80cc3d_GroupAssertionsTest_s.java | 41a1ce48973a57b5432421d50c522e2822d54fed | []
| no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 6,476 | java | /*
* Copyright (c) 2007-2010 Concurrent, Inc. All Rights Reserved.
*
* Project and contact information: http://www.cascading.org/
*
* This file is part of the Cascading project.
*
* Cascading 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.
*
* Cascading 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 Cascading. If not, see <http://www.gnu.org/licenses/>.
*/
package cascading.operation.assertion;
import cascading.CascadingTestCase;
import cascading.flow.FlowProcess;
import cascading.operation.AssertionException;
import cascading.operation.ConcreteCall;
import cascading.operation.GroupAssertion;
import cascading.tuple.Fields;
import cascading.tuple.Tuple;
import cascading.tuple.TupleEntry;
/**
*
*/
public class GroupAssertionsTest extends CascadingTestCase
{
public GroupAssertionsTest()
{
super( "group assertions test" );
}
private TupleEntry getEntry( Tuple tuple )
{
return new TupleEntry( Fields.size( tuple.size() ), tuple );
}
private void assertFail( GroupAssertion assertion, TupleEntry groupEntry, TupleEntry... values )
{
ConcreteCall operationCall = new ConcreteCall();
operationCall.setGroup( groupEntry );
assertion.start( FlowProcess.NULL, operationCall );
for( TupleEntry value : values )
{
operationCall.setArguments( value );
assertion.aggregate( FlowProcess.NULL, operationCall );
}
try
{
operationCall.setArguments( null );
assertion.doAssert( FlowProcess.NULL, operationCall );
fail();
}
catch( AssertionException exception )
{
//System.out.println( "exception.getMessage() = " + exception.getMessage() );
// do nothing
}
}
private void assertPass( GroupAssertion assertion, TupleEntry groupEntry, TupleEntry... values )
{
ConcreteCall operationCall = new ConcreteCall();
operationCall.setGroup( groupEntry );
assertion.start( null, operationCall );
for( TupleEntry value : values )
{
operationCall.setArguments( value );
assertion.aggregate( FlowProcess.NULL, operationCall );
}
operationCall.setArguments( null );
assertion.doAssert( FlowProcess.NULL, operationCall );
}
public void testSizeEquals()
{
GroupAssertion assertion = new AssertGroupSizeEquals( 1 );
assertPass( assertion, getEntry( new Tuple( 1 ) ), getEntry( new Tuple( 1 ) ) );
assertFail( assertion, getEntry( new Tuple( (Comparable) null ) ) );
assertPass( assertion, getEntry( new Tuple( "0", 1 ) ), getEntry( new Tuple( "0", 1 ) ) );
assertFail( assertion, getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ) );
assertion = new AssertGroupSizeEquals( "1", 1 );
assertPass( assertion, getEntry( new Tuple( 1 ) ), getEntry( new Tuple( 1 ) ) );
assertFail( assertion, getEntry( new Tuple( 1 ) ), getEntry( new Tuple( 1 ) ), getEntry( new Tuple( 1 ) ) );
assertPass( assertion, getEntry( new Tuple( (Comparable) null ) ) );
assertPass( assertion, getEntry( new Tuple( "0", 1 ) ), getEntry( new Tuple( "0", 1 ) ) );
assertPass( assertion, getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ) );
}
public void testSizeLessThan()
{
GroupAssertion assertion = new AssertGroupSizeLessThan( 2 );
assertPass( assertion, getEntry( new Tuple( 1 ) ), getEntry( new Tuple( 1 ) ) );
assertFail( assertion, getEntry( new Tuple( (Comparable) null ) ), getEntry( new Tuple( (Comparable) null ) ), getEntry( new Tuple( (Comparable) null ) ) );
assertPass( assertion, getEntry( new Tuple( "0", 1 ) ), getEntry( new Tuple( "0", 1 ) ) );
assertFail( assertion, getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ) );
assertion = new AssertGroupSizeLessThan( "1", 2 );
assertPass( assertion, getEntry( new Tuple( 1 ) ), getEntry( new Tuple( 1 ) ) );
assertFail( assertion, getEntry( new Tuple( 1 ) ), getEntry( new Tuple( 1 ) ), getEntry( new Tuple( 1 ) ) );
assertPass( assertion, getEntry( new Tuple( (Comparable) null ) ), getEntry( new Tuple( (Comparable) null ) ), getEntry( new Tuple( (Comparable) null ) ) );
assertPass( assertion, getEntry( new Tuple( "0", 1 ) ), getEntry( new Tuple( "0", 1 ) ) );
assertPass( assertion, getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ) );
}
public void testSizeMoreThan()
{
GroupAssertion assertion = new AssertGroupSizeMoreThan( 1 );
assertPass( assertion, getEntry( new Tuple( (Comparable) 1 ) ), getEntry( new Tuple( (Comparable) null ) ), getEntry( new Tuple( (Comparable) null ) ) );
assertFail( assertion, getEntry( new Tuple( 1 ) ), getEntry( new Tuple( 1 ) ) );
assertPass( assertion, getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ) );
assertFail( assertion, getEntry( new Tuple( "0", 1 ) ), getEntry( new Tuple( "0", 1 ) ) );
assertion = new AssertGroupSizeMoreThan( "1", 1 );
assertPass( assertion, getEntry( new Tuple( (Comparable) 1 ) ), getEntry( new Tuple( (Comparable) null ) ), getEntry( new Tuple( (Comparable) null ) ) );
assertFail( assertion, getEntry( new Tuple( 1 ) ), getEntry( new Tuple( 1 ) ) );
assertPass( assertion, getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ), getEntry( new Tuple( "0", null ) ) );
assertPass( assertion, getEntry( new Tuple( "0", 1 ) ), getEntry( new Tuple( "0", 1 ) ) );
}
}
| [
"[email protected]"
]
| |
de86422056a918db2e658eacacf265da27c4b072 | 0ca9a0873d99f0d69b78ed20292180f513a20d22 | /saved/sources/android/support/p001v4/widget/TintableImageSourceView.java | 928a5f83cf667e04280ed91be75231c94e545630 | []
| no_license | Eliminater74/com.google.android.tvlauncher | 44361fbbba097777b99d7eddd6e03d4bbe5f4d60 | e8284f9970d77a05042a57e9c2173856af7c4246 | refs/heads/master | 2021-01-14T23:34:04.338366 | 2020-02-24T16:39:53 | 2020-02-24T16:39:53 | 242,788,539 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 643 | java | package android.support.p001v4.widget;
import android.content.res.ColorStateList;
import android.graphics.PorterDuff;
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
@RestrictTo({RestrictTo.Scope.LIBRARY_GROUP_PREFIX})
/* renamed from: android.support.v4.widget.TintableImageSourceView */
public interface TintableImageSourceView {
@Nullable
ColorStateList getSupportImageTintList();
@Nullable
PorterDuff.Mode getSupportImageTintMode();
void setSupportImageTintList(@Nullable ColorStateList colorStateList);
void setSupportImageTintMode(@Nullable PorterDuff.Mode mode);
}
| [
"[email protected]"
]
| |
52fc1fb7bca6108165de4d0bb631840603cbf462 | 22c46d23fc671fe721178cdecffbce444ee947ff | /src/main/java/com/sample/test/api/request/TransactionsByUserIdRequest.java | d2d0ea44e6376d8937afb1e792b7f70ec65d19be | []
| no_license | andresIngSof/andres-prado-sample-java-test | 8e93cf21b2bb9795622fff4bf595c8635997e364 | 28f79b1281754de9ba73bb0b240b3a3a75dfc341 | refs/heads/master | 2020-11-27T14:02:47.544498 | 2019-12-24T03:11:14 | 2019-12-24T03:11:14 | 229,475,309 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 970 | java | package com.sample.test.api.request;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.sample.test.api.exception.APIException;
import com.sample.test.api.utils.Constants;
import java.util.Objects;
/**
*
* @author : Andrés Prado Cruz
* @email : [email protected]
* @class : TransactionsByUserIdRequest.java
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class TransactionsByUserIdRequest {
private Long user_id;
/**
* Verifica que los campos requeridos se encuentren presentes en el request.
* @throws APIException si falta alguno de los campos requeridos.
*/
public void checkNotNull() throws APIException {
if(Objects.isNull(user_id)) {
throw new APIException(String.format(Constants.REQUIRED_PARAM, "user_id"));
}
}
public Long getUser_id() {
return user_id;
}
public void setUser_id(Long user_id) {
this.user_id = user_id;
}
}
| [
"[email protected]"
]
| |
8a5f4fb38d2a52fbdced68f720e0df54ff282f5f | cf1e88f3048633c5251de87595de1a825b7064d8 | /src/main/java/com/fenghua/auto/order/service/OrderHeaderService.java | cf988e7b430dc1b37439323fd9e2f0b8ab117799 | []
| no_license | fightingBilling/skeleton-spring-web | 64b77e2dc15849dbeecf48809e538e1b5e734721 | f0c23867a7df6a6ab6239f747a66f6714800d793 | refs/heads/master | 2021-01-19T11:46:21.927365 | 2015-12-02T01:56:23 | 2015-12-02T01:56:23 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 340 | java | /**
*
*/
package com.fenghua.auto.order.service;
import com.fenghua.auto.backend.service.BaseService;
import com.fenghua.auto.order.domain.OrderHeader;
/**
* Service接口类
*
* @author 王直元
* @createTime 2015-11-25 11:11:35
*
*/
public interface OrderHeaderService extends BaseService<OrderHeader> {
}
| [
"[email protected]"
]
| |
d9c5d1ce7bcba8775412fe59ac681a8fa1b6dcd9 | 2c1cdf0a73be4277f49e45d95ec8e444672446c1 | /src/main/java/zhangjie/web/interceptor/QryParamCollector.java | 38ff496edd64361914cd0e88bb4398a3425cdc4a | []
| no_license | woodenone-ghost/bishe | e6b0ae05ef8d6ec00863deaff10cfceb9525b026 | 37e56898c20c8a856f0cdb94accb0765a1de6866 | refs/heads/master | 2022-12-21T05:15:44.432866 | 2019-06-18T06:59:42 | 2019-06-18T06:59:42 | 170,657,126 | 0 | 0 | null | 2022-12-16T04:39:32 | 2019-02-14T08:41:03 | JavaScript | UTF-8 | Java | false | false | 1,612 | java | package zhangjie.web.interceptor;
import java.util.HashMap;
import java.util.Map;
import java.util.function.BiConsumer;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import zhangjie.constants.Constants;
/**
* 将页面上送来的_QRY_开头的查询参数,整合成一个map
*
* @author 60569
*
*/
public class QryParamCollector extends HandlerInterceptorAdapter {
@SuppressWarnings("unused")
private static final Logger logger = Logger.getLogger(QryParamCollector.class);
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
if (handler instanceof HandlerMethod) {
final Map<String, String> qryParamMap = new HashMap<String, String>();
Map<String, String[]> params = request.getParameterMap();
if (params != null) {
params.forEach(new BiConsumer<String, String[]>() {
public void accept(String key, String[] values) {
if (key.startsWith(Constants.QRY_PARAM_NM_PREFIX) && values != null && values.length == 1) {
qryParamMap.put(key.substring(Constants.QRY_PARAM_NM_PREFIX_LEN), values[0].trim());
}
}
});
}
// 将整合结果放到Request上下文中,供Controller使用
if (!qryParamMap.isEmpty()) {
request.setAttribute(Constants.QRY_PARAM_MAP, qryParamMap);
}
return true;
} else {
return super.preHandle(request, response, handler);
}
}
}
| [
"[email protected]"
]
| |
8273b4f5aa40149932c965c6e71838f26882a212 | e5d53701f07991186bdd6d18de3b5247a293e88e | /src/test/java/com/galvanize/jalbersh/springplayground/model/WordCount.java | 8c3e85013d1f8c65ab81c32879709c7c02b8bb91 | []
| no_license | jalbersh/spring-playground | de193bb94dad0e465fcc48dc694258f8445bf121 | f76521a1be08049672cccfe3bfdce93b27855cc0 | refs/heads/master | 2020-03-24T01:07:05.075962 | 2018-09-09T01:24:36 | 2018-09-09T01:24:36 | 142,323,061 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 639 | java | package com.galvanize.jalbersh.springplayground.model;
public class WordCount {
private String word;
private Integer count;
public WordCount() {
}
public WordCount(String word, Integer count) {
this.word = word;
this.count = count;
}
public WordCount(String word) {
this.word = word;
this.count = 0;
}
public String getWord() {
return word;
}
public void setWord(String word) {
this.word = word;
}
public Integer getCount() {
return count;
}
public void setCount(Integer count) {
this.count = count;
}
}
| [
"[email protected]"
]
| |
e94be10a086045ea9f1661295c4ad0b1e39de48c | 9ab8785a5ed278ce952220efbb3766a53bb30472 | /app/src/main/java/cc/colorcat/newmvp/web/IWebView.java | 462e62f3d431c57c3f6c6606e23819b6d00c1ff3 | []
| no_license | fireworld/NewMvp | 45c381013c9fc22ba220e8f24a325e8fd1b431ed | 8fb6afbfab3465a7bc3aa5a5bb90a3cee9cc1aa5 | refs/heads/master | 2021-01-11T14:17:21.871196 | 2017-10-25T05:51:56 | 2017-10-25T05:51:56 | 81,307,244 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,883 | java | package cc.colorcat.newmvp.web;
import android.content.Context;
import android.graphics.Bitmap;
import android.webkit.ValueCallback;
import android.webkit.WebView;
/**
* Created by cxx on 2017/2/9.
* [email protected]
*/
public interface IWebView {
/**
* 在此方法中创建新的 {@link WebView} 并添加到视图中
*/
void onCreateWebView();
/**
* 在此方法中销毁原来的 {@link WebView} 并重新创建,然后添加到视图中
*/
void onRecreateWebView();
/**
* @return 添加成功返回 true,否则返回 false
*/
boolean addPageLoadListener(PageLoadListener listener);
/**
* @return 移除成功返回 true,否则返回 false
*/
boolean removePageLoadListener(PageLoadListener listener);
/**
* @return 添加成功返回 true,否则返回 false
*/
boolean addErrorListener(ErrorListener listener);
/**
* @return 移除成功返回 true,否则返回 false
*/
boolean removeErrorListener(ErrorListener listener);
/**
* 在此方法中载入 url
* note: 此方法必须在 {@link WebView} 创建后调用
*
* @param url http / https
* @throws IllegalStateException 如果 {@link WebView} 没有创建,即为空的时候抛出此异常
*/
void loadUrl(String url);
/**
* @param data a String of data in the given encoding
* @param mimeType the MIME type of the data, e.g. 'text/html'
* @param encoding the encoding of the data
*/
void loadData(String data, String mimeType, String encoding);
/**
* 刷新当前页面
*/
void reload();
/**
* @param script the JavaScript to execute.
* @param resultCallback A callback to be invoked when the script execution
* completes with the result of the execution (if any).
* May be null if no notificaion of the result is required.
*/
void evaluateJavascript(String script, ValueCallback<String> resultCallback);
/**
* @return {@link WebView.HitTestResult#getType()}
*/
int getHitTestType();
/**
* 获取上下文环境变量
*/
Context getContext();
/**
* 在此方法中销毁 {@link WebView}, 回收 {@link WebView} 的资源
*/
void onDestroyWebView();
interface PageLoadListener {
void onPageStarted(String url, Bitmap favicon);
void onPageFinished(String url);
}
interface ErrorListener {
void onReceivedError(int errorCode, String description, String failingUrl);
}
class SimplePageLoadListener implements PageLoadListener {
@Override
public void onPageStarted(String url, Bitmap favicon) {
}
@Override
public void onPageFinished(String url) {
}
}
}
| [
"[email protected]"
]
| |
693caf8c538aaaaef265be44f712c7eb3409c6cb | 37c9a638bea48f066e414847fef8001bb06c54e1 | /src/test/java/org/example/d/PricingTest.java | f4de293dd47bc70515831a753bf20067f10ca100 | []
| no_license | BenjaminLimb/web-test-framework-tutorial | 9968f87cf8180767da4a1e9f024e77309a2c05d7 | f02c81264f8c5c60cb32c77dc44f7f209aaeaf35 | refs/heads/master | 2016-09-01T19:41:30.166973 | 2015-03-30T16:56:34 | 2015-03-30T16:56:34 | 33,131,222 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,462 | java | package org.example.d;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.syftkog.web.test.framework.Driver;
import org.syftkog.web.test.framework.TestCaseContext;
import org.testng.annotations.Test;
/**
*
* @author benjaminlimb
*/
public class PricingTest {
public static Logger LOG = LoggerFactory.getLogger(PricingTest.class);
@Test(groups = "acceptance")
public void googleSearchTest() {
TestCaseContext context = new TestCaseContext();
Driver driver = context.getDriver();
GoogleSearchPage googlePage = new GoogleSearchPage(driver).load();
googlePage.searchFor("Software Test Professionals Spring 2015");
STPConferencePage stpPage = googlePage.firstResult.clickAndLoadPage(STPConferencePage.class);
//stpPage.assertPage().loaded();// This truly isn't necessary because by it's already implied by the clickAndLoadPage().
driver.navigateBack();
googlePage.assertPage().loaded();
driver.close();
}
/**
* Note that you can use the context directly because it implements the
* HasDriver interface.
*/
@Test(groups = "regression")
public void pricingTest() {
TestCaseContext context = new TestCaseContext();
STPConferencePage stpPage = new STPConferencePage(context).load();
STPPricingPage stpPricingPage = stpPage.clickPricingButtonAndLoadPricingPage();
stpPricingPage.clickRegisterNowAndLoadRegistrationPage();
context.getDriver().close();
}
}
| [
"[email protected]"
]
| |
adc33891fb328d147fe3cf75e725a10f3729a1ed | 84b3fb5385d65fc87f612fc75f9b63b166f2c1d3 | /Grimoires/src/uk/ac/soton/ecs/grimoires/server/impl/wsdl/autogen/GetAllWSDLFilesResponse.java | a4c8c7f76ddaf74056da4320949e19a7087131eb | [
"BSD-3-Clause"
]
| permissive | wjfang/grimoires | a65ee272f5ef34a8021eacd1ac7d0800b7f7a85a | 3afaf971752f7fb6eb9ca4d182adc13445f32ed0 | refs/heads/master | 2021-01-19T09:55:40.830621 | 2008-05-15T09:17:29 | 2008-05-15T09:17:29 | 32,545,455 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,492 | java | /**
* GetAllWSDLFilesResponse.java
*
* This file was auto-generated from WSDL
* by the Apache Axis 1.2RC3 Feb 28, 2005 (10:15:14 EST) WSDL2Java emitter.
*/
package uk.ac.soton.ecs.grimoires.server.impl.wsdl.autogen;
public class GetAllWSDLFilesResponse implements java.io.Serializable {
private java.lang.String[] url;
public GetAllWSDLFilesResponse() {
}
public GetAllWSDLFilesResponse(
java.lang.String[] url) {
this.url = url;
}
/**
* Gets the url value for this GetAllWSDLFilesResponse.
*
* @return url
*/
public java.lang.String[] getUrl() {
return url;
}
/**
* Sets the url value for this GetAllWSDLFilesResponse.
*
* @param url
*/
public void setUrl(java.lang.String[] url) {
this.url = url;
}
public java.lang.String getUrl(int i) {
return this.url[i];
}
public void setUrl(int i, java.lang.String _value) {
this.url[i] = _value;
}
private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof GetAllWSDLFilesResponse)) return false;
GetAllWSDLFilesResponse other = (GetAllWSDLFilesResponse) obj;
if (obj == null) return false;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsCalc == obj);
}
__equalsCalc = obj;
boolean _equals;
_equals = true &&
((this.url==null && other.getUrl()==null) ||
(this.url!=null &&
java.util.Arrays.equals(this.url, other.getUrl())));
__equalsCalc = null;
return _equals;
}
private boolean __hashCodeCalc = false;
public synchronized int hashCode() {
if (__hashCodeCalc) {
return 0;
}
__hashCodeCalc = true;
int _hashCode = 1;
if (getUrl() != null) {
for (int i=0;
i<java.lang.reflect.Array.getLength(getUrl());
i++) {
java.lang.Object obj = java.lang.reflect.Array.get(getUrl(), i);
if (obj != null &&
!obj.getClass().isArray()) {
_hashCode += obj.hashCode();
}
}
}
__hashCodeCalc = false;
return _hashCode;
}
}
| [
"wjfang@40f0876b-8a1f-0410-b2cd-f31c4a8ce603"
]
| wjfang@40f0876b-8a1f-0410-b2cd-f31c4a8ce603 |
0425ff0e392887a79097d9e90ab994779da33703 | 0af8b92686a58eb0b64e319b22411432aca7a8f3 | /single-large-project/src/test/java/org/gradle/test/performancenull_329/Testnull_32841.java | 9104457124eda6a9b29baab4cab3b7cf12811668 | []
| no_license | gradle/performance-comparisons | b0d38db37c326e0ce271abebdb3c91769b860799 | e53dc7182fafcf9fedf07920cbbea8b40ee4eef4 | refs/heads/master | 2023-08-14T19:24:39.164276 | 2022-11-24T05:18:33 | 2022-11-24T05:18:33 | 80,121,268 | 17 | 15 | null | 2022-09-30T08:04:35 | 2017-01-26T14:25:33 | null | UTF-8 | Java | false | false | 308 | java | package org.gradle.test.performancenull_329;
import static org.junit.Assert.*;
public class Testnull_32841 {
private final Productionnull_32841 production = new Productionnull_32841("value");
@org.junit.Test
public void test() {
assertEquals(production.getProperty(), "value");
}
} | [
"[email protected]"
]
| |
0ffc9eee9d61c571a367e09ca050e7648b39fc13 | 8a45c4f546ec384ff04f267ceff881a7a4fd354e | /app/src/test/java/com/example/afrijal/belajarvolley/ExampleUnitTest.java | 9a8d33aa879f9363ce39ae6ed011883a44d025a8 | []
| no_license | afrijaldz/Cek-Tagihan-PLN | 2d538b4876503583bd9650ceaaa283b39d3e0693 | b60bdb67bf75e8d67316b898c4b4585d95a66ec5 | refs/heads/master | 2020-12-25T05:45:16.501028 | 2016-12-26T07:19:14 | 2016-12-26T07:19:14 | 64,066,747 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 326 | java | package com.example.afrijal.belajarvolley;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
]
| |
6e919323821911489bfa539acd8c51cafd521c43 | 08345dde7830b0080ae84c0dee096053febea69d | /crazyLectures/src/main/java/com/sumnear/c0604/FinalErrorTest.java | 7f152a3d965b59f78f7fcece279d5f7601e7bc9a | []
| no_license | sumnear/codeLife | fbf2a929fd4b829c1cdd69464b30e169a5bc7fcf | 227a2a2480d27fd1961e62f89173216d045736b1 | refs/heads/master | 2022-12-23T07:36:10.508350 | 2021-06-27T13:06:34 | 2021-06-27T13:06:34 | 198,769,670 | 0 | 0 | null | 2022-12-16T05:24:26 | 2019-07-25T06:18:32 | Java | UTF-8 | Java | false | false | 669 | java | package com.sumnear.c0604;
/**
* Description:
* <br/>网站: <a href="http://www.crazyit.org">疯狂Java联盟</a>
* <br/>Copyright (C), 2001-2016, Yeeku.H.Lee
* <br/>This program is protected by copyright laws.
* <br/>Program Name:
* <br/>Date:
* @author Yeeku.H.Lee [email protected]
* @version 1.0
*/
public class FinalErrorTest
{
// 定义一个final修饰的实例变量
// 系统不会对final成员变量进行默认初始化
final int age;
{
// age没有初始化,所以此处代码将引起错误。
// System.out.println(age);
age = 6;
System.out.println(age);
}
public static void main(String[] args)
{
new FinalErrorTest();
}
}
| [
"[email protected]"
]
| |
b1959ab804655389c15a9a1df63ec830ad74ea7f | 11e64f2d18b3db1849fbf94b67ccdf4b1e49f698 | /Filesystem.edit/src/jfb/examples/gmf/filesystem/provider/FilesystemEditPlugin.java | 3038864664062efdb8f80d273df346263cc58d0a | []
| no_license | AntoineDelacroixCelad/Test2Models | 0cd6dc8ea8266297f62a2c5adbf38e612af7aa7e | 69aca93cf5f898ec80857f98c1ae9f99331a0b47 | refs/heads/master | 2016-09-01T12:19:15.228158 | 2015-11-23T13:44:20 | 2015-11-23T13:44:20 | 46,706,680 | 0 | 0 | null | null | null | null | ISO-8859-3 | Java | false | false | 3,402 | java | /*
* Copyright (c) 2009, Jean-François Brazeau. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. 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.
*
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIEDWARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package jfb.examples.gmf.filesystem.provider;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.util.ResourceLocator;
/**
* This is the central singleton for the Filesystem edit plugin.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public final class FilesystemEditPlugin extends EMFPlugin {
/**
* Keep track of the singleton.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static final FilesystemEditPlugin INSTANCE = new FilesystemEditPlugin();
/**
* Keep track of the singleton.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
private static Implementation plugin;
/**
* Create the instance.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public FilesystemEditPlugin() {
super
(new ResourceLocator [] {
});
}
/**
* Returns the singleton instance of the Eclipse plugin.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the singleton instance.
* @generated
*/
@Override
public ResourceLocator getPluginResourceLocator() {
return plugin;
}
/**
* Returns the singleton instance of the Eclipse plugin.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @return the singleton instance.
* @generated
*/
public static Implementation getPlugin() {
return plugin;
}
/**
* The actual implementation of the Eclipse <b>Plugin</b>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public static class Implementation extends EclipsePlugin {
/**
* Creates an instance.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public Implementation() {
super();
// Remember the static instance.
//
plugin = this;
}
}
}
| [
"[email protected]"
]
| |
c8c58de0e9fad8c64e2a88638df9c6d7bb2ba967 | 3934e6d44a22897e66267e8c15e628e8ec1a3ee5 | /org.lispdev/src/org/lispdev/views/repl/ReplEnterTrigger.java | 3410538b2d8e4a0ba39175bde88a9f45f1903c19 | []
| no_license | amarquesbra/lispdev | d705a89c9de07e33e7d7af38cc682a33a635c509 | 608c43ad21d8447abe7a08f0e5089b5e7fe632ab | refs/heads/master | 2021-01-19T06:24:34.716972 | 2009-10-29T05:21:02 | 2009-10-29T05:21:02 | 39,547,411 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 910 | java | /**
*
*/
package org.lispdev.views.repl;
import org.eclipse.swt.events.VerifyEvent;
/**
* @author sk
*
*/
public class ReplEnterTrigger extends ReplInputTrigger
{
private int stateMask;
/**
* @param r - repl to connect with
* @param stateMask - one of the following: SWT.NONE, or combination of
* SWT.ALT, SWT.CTRL, SWT.SHIFT (combination performed using |, example:
* SWT.ALT | SWT.CTRL
*/
public ReplEnterTrigger(Repl repl, int stateMask, int partitionResolutionFlag)
{
super(repl,partitionResolutionFlag);
this.stateMask = stateMask;
}
/* (non-Javadoc)
* @see org.lispdev.views.repl.ReplInputTrigger#check(org.eclipse.swt.events.VerifyEvent)
*/
@Override
protected boolean check(VerifyEvent event)
{
return (event.stateMask == stateMask &&
(event.keyCode == '\r' || event.keyCode == '\n'));
}
}
| [
"sergey.kolos@c960db1b-0f56-0410-bd44-834b428c456c"
]
| sergey.kolos@c960db1b-0f56-0410-bd44-834b428c456c |
004a8d3f9e269d38695bab27d1e5e42be988ece3 | 19df637823300ca8b82debd02e5937a090c82956 | /src/main/java/valandur/webapi/cache/misc/CachedCatalogType.java | 6b6157469abd2f152a26f288592fedd25eef2c07 | [
"MIT"
]
| permissive | Dawn-MC/Web-API | 51b8d77da2409f09301bb7958eb6fc5ef1b12bb0 | 8d9cac81685d7d6200b54450461aaf63d4be7fae | refs/heads/master | 2021-01-20T04:09:22.666815 | 2017-06-05T22:30:23 | 2017-06-05T22:30:23 | 89,648,309 | 0 | 0 | null | 2017-06-05T22:30:24 | 2017-04-27T23:21:36 | Java | UTF-8 | Java | false | false | 539 | java | package valandur.webapi.cache.misc;
import org.spongepowered.api.CatalogType;
import valandur.webapi.cache.CachedObject;
public class CachedCatalogType extends CachedObject {
private String id;
public String getId() {
return id;
}
private String name;
public String getName() {
return name;
}
public CachedCatalogType(CatalogType catalogType) {
super(catalogType);
this.id = catalogType.getId();
this.name = catalogType.getName();
}
}
| [
"[email protected]"
]
| |
35b137406920237004ca9a835450a77cd0fd942e | 5f64b948eae8c907139f5b2161b5803a89e1191f | /wltcloud-hanlp/src/test/java/com/hankcs/book/ch08/DemoHMMNER.java | df63776969805e5e59c6485b385b04fbef73fc07 | []
| no_license | wulitian/wltcloud | 0e238ab6a26504c123e1d8b13e02babdc45b864b | 1eef4238c99a6bc6d8dc3e955803e6178263c72e | refs/heads/master | 2022-03-14T07:57:52.215538 | 2019-11-29T10:24:57 | 2019-11-29T10:24:57 | 217,468,880 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,528 | java | /*
* <author>Han He</author>
* <email>[email protected]</email>
* <create-date>2018-07-27 8:52 PM</create-date>
*
* <copyright file="HMMNER.java">
* Copyright (c) 2018, Han He. All Rights Reserved, http://www.hankcs.com/
* This source is subject to Han He. Please contact Han He for more information.
* </copyright>
*/
package com.hankcs.book.ch08;
import com.hankcs.hanlp.corpus.PKU;
import com.hankcs.hanlp.model.hmm.HMMNERecognizer;
import com.hankcs.hanlp.model.perceptron.PerceptronPOSTagger;
import com.hankcs.hanlp.model.perceptron.PerceptronSegmenter;
import com.hankcs.hanlp.model.perceptron.utility.Utility;
import com.hankcs.hanlp.tokenizer.lexical.AbstractLexicalAnalyzer;
import com.hankcs.hanlp.tokenizer.lexical.NERecognizer;
import java.io.IOException;
import java.util.Map;
/**
* 《自然语言处理入门》8.5.2 基于隐马尔可夫模型序列标注的命名实体识别
* 配套书籍:http://nlp.hankcs.com/book.php
* 讨论答疑:https://bbs.hankcs.com/
*
* @author hankcs
* @see <a href="http://nlp.hankcs.com/book.php">《自然语言处理入门》</a>
* @see <a href="https://bbs.hankcs.com/">讨论答疑</a>
*/
public class DemoHMMNER
{
public static void main(String[] args) throws IOException
{
NERecognizer recognizer = train(PKU.PKU199801_TRAIN);
test(recognizer);
}
public static NERecognizer train(String corpus) throws IOException
{
HMMNERecognizer recognizer = new HMMNERecognizer();
recognizer.train(corpus); // data/test/pku98/199801-train.txt
return recognizer;
}
public static void test(NERecognizer recognizer) throws IOException
{
String[] wordArray = {"华北", "电力", "公司"}; // 构造单词序列
String[] posArray = {"ns", "n", "n"}; // 构造词性序列
String[] nerTagArray = recognizer.recognize(wordArray, posArray); // 序列标注
for (int i = 0; i < wordArray.length; i++)
System.out.printf("%s\t%s\t%s\t\n", wordArray[i], posArray[i], nerTagArray[i]);
AbstractLexicalAnalyzer analyzer = new AbstractLexicalAnalyzer(new PerceptronSegmenter(), new PerceptronPOSTagger(), recognizer);
analyzer.enableCustomDictionary(false);
System.out.println(analyzer.analyze("华北电力公司董事长谭旭光和秘书胡花蕊来到美国纽约现代艺术博物馆参观"));
Map<String, double[]> scores = Utility.evaluateNER(recognizer, PKU.PKU199801_TEST);
Utility.printNERScore(scores);
}
}
| [
"[email protected]"
]
| |
40d9678df5033c5610a98eb9314c18637bb76f04 | c443dc3f9e799d79f5e1dd709c54c950858251d9 | /drools-spring-app/src/main/java/sbnz/service/IngredientService.java | 63deab482e4849079c63b123a2e6b85bdc20eeda | []
| no_license | Kendra1/Health-Feast | a0d98a201800a1389801d1e05063808be40212af | e33991926c5ca802b7e00224edaf24df87b8f39c | refs/heads/master | 2022-12-11T16:15:35.174381 | 2020-09-07T10:45:08 | 2020-09-07T10:45:08 | 263,631,956 | 0 | 0 | null | 2020-09-07T10:29:13 | 2020-05-13T13:05:04 | Java | UTF-8 | Java | false | false | 190 | java | package sbnz.service;
import java.util.List;
import sbnz.model.Ingredient;
public interface IngredientService {
List<String> getIngredients();
Ingredient findByName(String name);
}
| [
"[email protected]"
]
| |
1625ab7bba19e82326f7e90fe975eef841247e29 | 55dd60fe01ee88deda273f9ab1e3616e390b2d5b | /JDK1.8/src/java/util/UUID.java | 81a58b51a4fa6faa5a890d820874dc2cd210276b | []
| no_license | wanghengGit/JDK-1 | d7c1a86ecadb2590c8d58a23c47fdd7ebfcc3a66 | 1be52fd27316c82e06296dbdd25e41ad3da37d12 | refs/heads/master | 2021-09-10T07:23:17.576037 | 2021-09-09T07:19:16 | 2021-09-09T07:19:16 | 202,044,942 | 0 | 0 | null | 2019-08-13T02:13:35 | 2019-08-13T02:13:34 | null | UTF-8 | Java | false | false | 15,505 | java | /*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package java.util;
import java.security.*;
/**
* A class that represents an immutable universally unique identifier (UUID).
* A UUID represents a 128-bit value.
*
* <p> There exist different variants of these global identifiers. The methods
* of this class are for manipulating the Leach-Salz variant, although the
* constructors allow the creation of any variant of UUID (described below).
*
* <p> The layout of a variant 2 (Leach-Salz) UUID is as follows:
*
* The most significant long consists of the following unsigned fields:
* <pre>
* 0xFFFFFFFF00000000 time_low
* 0x00000000FFFF0000 time_mid
* 0x000000000000F000 version
* 0x0000000000000FFF time_hi
* </pre>
* The least significant long consists of the following unsigned fields:
* <pre>
* 0xC000000000000000 variant
* 0x3FFF000000000000 clock_seq
* 0x0000FFFFFFFFFFFF node
* </pre>
*
* <p> The variant field contains a value which identifies the layout of the
* {@code UUID}. The bit layout described above is valid only for a {@code
* UUID} with a variant value of 2, which indicates the Leach-Salz variant.
*
* <p> The version field holds a value that describes the type of this {@code
* UUID}. There are four different basic types of UUIDs: time-based, DCE
* security, name-based, and randomly generated UUIDs. These types have a
* version value of 1, 2, 3 and 4, respectively.
*
* <p> For more information including algorithms used to create {@code UUID}s,
* see <a href="http://www.ietf.org/rfc/rfc4122.txt"> <i>RFC 4122: A
* Universally Unique IDentifier (UUID) URN Namespace</i></a>, section 4.2
* "Algorithms for Creating a Time-Based UUID".
*
* @since 1.5
* @date 20200328
* @author kit
*/
public final class UUID implements java.io.Serializable, Comparable<UUID> {
/**
* Explicit serialVersionUID for interoperability.
*/
private static final long serialVersionUID = -4856846361193249489L;
/*
* The most significant 64 bits of this UUID.
*
* @serial
*/
private final long mostSigBits;
/*
* The least significant 64 bits of this UUID.
*
* @serial
*/
private final long leastSigBits;
/*
* The random number generator used by this class to create random
* based UUIDs. In a holder class to defer initialization until needed.
*/
private static class Holder {
static final SecureRandom numberGenerator = new SecureRandom();
}
// Constructors and Factories
/*
* Private constructor which uses a byte array to construct the new UUID.
*/
private UUID(byte[] data) {
long msb = 0;
long lsb = 0;
assert data.length == 16 : "data must be 16 bytes in length";
for (int i=0; i<8; i++)
msb = (msb << 8) | (data[i] & 0xff);
for (int i=8; i<16; i++)
lsb = (lsb << 8) | (data[i] & 0xff);
this.mostSigBits = msb;
this.leastSigBits = lsb;
}
/**
* Constructs a new {@code UUID} using the specified data. {@code
* mostSigBits} is used for the most significant 64 bits of the {@code
* UUID} and {@code leastSigBits} becomes the least significant 64 bits of
* the {@code UUID}.
*
* @param mostSigBits
* The most significant bits of the {@code UUID}
*
* @param leastSigBits
* The least significant bits of the {@code UUID}
*/
public UUID(long mostSigBits, long leastSigBits) {
this.mostSigBits = mostSigBits;
this.leastSigBits = leastSigBits;
}
/**
* Static factory to retrieve a type 4 (pseudo randomly generated) UUID.
*
* The {@code UUID} is generated using a cryptographically strong pseudo
* random number generator.
*
* @return A randomly generated {@code UUID}
*/
public static UUID randomUUID() {
SecureRandom ng = Holder.numberGenerator;
byte[] randomBytes = new byte[16];
ng.nextBytes(randomBytes);
randomBytes[6] &= 0x0f; /* clear version */
randomBytes[6] |= 0x40; /* set to version 4 */
randomBytes[8] &= 0x3f; /* clear variant */
randomBytes[8] |= 0x80; /* set to IETF variant */
return new UUID(randomBytes);
}
/**
* Static factory to retrieve a type 3 (name based) {@code UUID} based on
* the specified byte array.
*
* @param name
* A byte array to be used to construct a {@code UUID}
*
* @return A {@code UUID} generated from the specified array
*/
public static UUID nameUUIDFromBytes(byte[] name) {
MessageDigest md;
try {
md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException nsae) {
throw new InternalError("MD5 not supported", nsae);
}
byte[] md5Bytes = md.digest(name);
md5Bytes[6] &= 0x0f; /* clear version */
md5Bytes[6] |= 0x30; /* set to version 3 */
md5Bytes[8] &= 0x3f; /* clear variant */
md5Bytes[8] |= 0x80; /* set to IETF variant */
return new UUID(md5Bytes);
}
/**
* Creates a {@code UUID} from the string standard representation as
* described in the {@link #toString} method.
*
* @param name
* A string that specifies a {@code UUID}
*
* @return A {@code UUID} with the specified value
*
* @throws IllegalArgumentException
* If name does not conform to the string representation as
* described in {@link #toString}
*
*/
public static UUID fromString(String name) {
String[] components = name.split("-");
if (components.length != 5)
throw new IllegalArgumentException("Invalid UUID string: "+name);
for (int i=0; i<5; i++)
components[i] = "0x"+components[i];
long mostSigBits = Long.decode(components[0]).longValue();
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[1]).longValue();
mostSigBits <<= 16;
mostSigBits |= Long.decode(components[2]).longValue();
long leastSigBits = Long.decode(components[3]).longValue();
leastSigBits <<= 48;
leastSigBits |= Long.decode(components[4]).longValue();
return new UUID(mostSigBits, leastSigBits);
}
// Field Accessor Methods
/**
* Returns the least significant 64 bits of this UUID's 128 bit value.
*
* @return The least significant 64 bits of this UUID's 128 bit value
*/
public long getLeastSignificantBits() {
return leastSigBits;
}
/**
* Returns the most significant 64 bits of this UUID's 128 bit value.
*
* @return The most significant 64 bits of this UUID's 128 bit value
*/
public long getMostSignificantBits() {
return mostSigBits;
}
/**
* The version number associated with this {@code UUID}. The version
* number describes how this {@code UUID} was generated.
*
* The version number has the following meaning:
* <ul>
* <li>1 Time-based UUID
* <li>2 DCE security UUID
* <li>3 Name-based UUID
* <li>4 Randomly generated UUID
* </ul>
*
* @return The version number of this {@code UUID}
*/
public int version() {
// Version is bits masked by 0x000000000000F000 in MS long
return (int)((mostSigBits >> 12) & 0x0f);
}
/**
* The variant number associated with this {@code UUID}. The variant
* number describes the layout of the {@code UUID}.
*
* The variant number has the following meaning:
* <ul>
* <li>0 Reserved for NCS backward compatibility
* <li>2 <a href="http://www.ietf.org/rfc/rfc4122.txt">IETF RFC 4122</a>
* (Leach-Salz), used by this class
* <li>6 Reserved, Microsoft Corporation backward compatibility
* <li>7 Reserved for future definition
* </ul>
*
* @return The variant number of this {@code UUID}
*/
public int variant() {
// This field is composed of a varying number of bits.
// 0 - - Reserved for NCS backward compatibility
// 1 0 - The IETF aka Leach-Salz variant (used by this class)
// 1 1 0 Reserved, Microsoft backward compatibility
// 1 1 1 Reserved for future definition.
return (int) ((leastSigBits >>> (64 - (leastSigBits >>> 62)))
& (leastSigBits >> 63));
}
/**
* The timestamp value associated with this UUID.
*
* <p> The 60 bit timestamp value is constructed from the time_low,
* time_mid, and time_hi fields of this {@code UUID}. The resulting
* timestamp is measured in 100-nanosecond units since midnight,
* October 15, 1582 UTC.
*
* <p> The timestamp value is only meaningful in a time-based UUID, which
* has version type 1. If this {@code UUID} is not a time-based UUID then
* this method throws UnsupportedOperationException.
*
* @throws UnsupportedOperationException
* If this UUID is not a version 1 UUID
* @return The timestamp of this {@code UUID}.
*/
public long timestamp() {
if (version() != 1) {
throw new UnsupportedOperationException("Not a time-based UUID");
}
return (mostSigBits & 0x0FFFL) << 48
| ((mostSigBits >> 16) & 0x0FFFFL) << 32
| mostSigBits >>> 32;
}
/**
* The clock sequence value associated with this UUID.
*
* <p> The 14 bit clock sequence value is constructed from the clock
* sequence field of this UUID. The clock sequence field is used to
* guarantee temporal uniqueness in a time-based UUID.
*
* <p> The {@code clockSequence} value is only meaningful in a time-based
* UUID, which has version type 1. If this UUID is not a time-based UUID
* then this method throws UnsupportedOperationException.
*
* @return The clock sequence of this {@code UUID}
*
* @throws UnsupportedOperationException
* If this UUID is not a version 1 UUID
*/
public int clockSequence() {
if (version() != 1) {
throw new UnsupportedOperationException("Not a time-based UUID");
}
return (int)((leastSigBits & 0x3FFF000000000000L) >>> 48);
}
/**
* The node value associated with this UUID.
*
* <p> The 48 bit node value is constructed from the node field of this
* UUID. This field is intended to hold the IEEE 802 address of the machine
* that generated this UUID to guarantee spatial uniqueness.
*
* <p> The node value is only meaningful in a time-based UUID, which has
* version type 1. If this UUID is not a time-based UUID then this method
* throws UnsupportedOperationException.
*
* @return The node value of this {@code UUID}
*
* @throws UnsupportedOperationException
* If this UUID is not a version 1 UUID
*/
public long node() {
if (version() != 1) {
throw new UnsupportedOperationException("Not a time-based UUID");
}
return leastSigBits & 0x0000FFFFFFFFFFFFL;
}
// Object Inherited Methods
/**
* Returns a {@code String} object representing this {@code UUID}.
*
* <p> The UUID string representation is as described by this BNF:
* <blockquote><pre>
* {@code
* UUID = <time_low> "-" <time_mid> "-"
* <time_high_and_version> "-"
* <variant_and_sequence> "-"
* <node>
* time_low = 4*<hexOctet>
* time_mid = 2*<hexOctet>
* time_high_and_version = 2*<hexOctet>
* variant_and_sequence = 2*<hexOctet>
* node = 6*<hexOctet>
* hexOctet = <hexDigit><hexDigit>
* hexDigit =
* "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
* | "a" | "b" | "c" | "d" | "e" | "f"
* | "A" | "B" | "C" | "D" | "E" | "F"
* }</pre></blockquote>
*
* @return A string representation of this {@code UUID}
*/
public String toString() {
return (digits(mostSigBits >> 32, 8) + "-" +
digits(mostSigBits >> 16, 4) + "-" +
digits(mostSigBits, 4) + "-" +
digits(leastSigBits >> 48, 4) + "-" +
digits(leastSigBits, 12));
}
/** Returns val represented by the specified number of hex digits. */
private static String digits(long val, int digits) {
long hi = 1L << (digits * 4);
return Long.toHexString(hi | (val & (hi - 1))).substring(1);
}
/**
* Returns a hash code for this {@code UUID}.
*
* @return A hash code value for this {@code UUID}
*/
public int hashCode() {
long hilo = mostSigBits ^ leastSigBits;
return ((int)(hilo >> 32)) ^ (int) hilo;
}
/**
* Compares this object to the specified object. The result is {@code
* true} if and only if the argument is not {@code null}, is a {@code UUID}
* object, has the same variant, and contains the same value, bit for bit,
* as this {@code UUID}.
*
* @param obj
* The object to be compared
*
* @return {@code true} if the objects are the same; {@code false}
* otherwise
*/
public boolean equals(Object obj) {
if ((null == obj) || (obj.getClass() != UUID.class))
return false;
UUID id = (UUID)obj;
return (mostSigBits == id.mostSigBits &&
leastSigBits == id.leastSigBits);
}
// Comparison Operations
/**
* Compares this UUID with the specified UUID.
*
* <p> The first of two UUIDs is greater than the second if the most
* significant field in which the UUIDs differ is greater for the first
* UUID.
*
* @param val
* {@code UUID} to which this {@code UUID} is to be compared
*
* @return -1, 0 or 1 as this {@code UUID} is less than, equal to, or
* greater than {@code val}
*
*/
public int compareTo(UUID val) {
// The ordering is intentionally set up so that the UUIDs
// can simply be numerically compared as two numbers
return (this.mostSigBits < val.mostSigBits ? -1 :
(this.mostSigBits > val.mostSigBits ? 1 :
(this.leastSigBits < val.leastSigBits ? -1 :
(this.leastSigBits > val.leastSigBits ? 1 :
0))));
}
}
| [
"[email protected]"
]
| |
728c799e4aca14a422dee1664bd6479c82091e60 | aee5df69cd38887110c09d3d2bd723cb6e8987d6 | /2.JavaCore/src/com/javarush/task/task15/task1528/Solution.java | 30c838c940c48775d52f323f3feaf79fbffa12bf | []
| no_license | siarheikorbut/JavaRush | 5e98158ad71594b2ad1b41342b51df39517341fc | 095690627248ed8cb4d2b1a3314c06333aef2235 | refs/heads/master | 2023-08-24T05:34:03.674176 | 2021-10-16T17:57:19 | 2021-10-16T17:57:19 | 306,656,990 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 712 | java | package com.javarush.task.task15.task1528;
/*
ООП. Hryvnia — тоже деньги
*/
public class Solution {
public static void main(String[] args) {
System.out.println(new Hryvnia().getAmount());
}
public static abstract class Money {
abstract Money getMoney();
public Object getAmount() {
return getMoney().getAmount();
}
}
//add your code below - добавь код ниже
public static class Hryvnia extends Money {
private double amount = 123d;
public Hryvnia getMoney() {
return this;
}
@Override
public Object getAmount() {
return amount;
}
}
} | [
"[email protected]"
]
| |
b7e6114889dbac7eb5efa3abbb99ecceb371ac69 | e87e42bbb9b99be0263b0d61a85eacf9520a955b | /cidaas/src/main/java/de/cidaas/sdk/android/helper/CidaasSDKHelper.java | 2d33e15dd244d35a4dacccb857d1145302fc13d2 | [
"MIT"
]
| permissive | exozet/cidaas-android-sdk | 24104409400e43ad989403eabf686b9a063845a1 | 477b1d7e3cddf753b70bfa6fecf700c790c29200 | refs/heads/master | 2023-02-23T06:31:28.018713 | 2021-01-20T13:12:58 | 2021-01-20T13:12:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 698 | java | package de.cidaas.sdk.android.helper;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
public class CidaasSDKHelper {
public static String codeChallengeMethod = "S256";
public static String contentType = "application/x-www-form-urlencoded";
public static boolean isInternetAvailable(final Context context) {
ConnectivityManager conManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = conManager.getActiveNetworkInfo();
return !((networkInfo == null) || (!networkInfo.isConnected()) || (!networkInfo.isAvailable()));
}
}
| [
"[email protected]"
]
| |
d12555d7a00b2b2762d3cd5a75e0026d9672e3ed | f46f1d2228b722e15a775baeeb8c66513453cbdf | /ui/de-lib/src/main/java/org/iplantc/de/analysis/client/events/SaveAnalysisParametersEvent.java | 81b3b78fa807f5937ef4ed36af06e177fe1cc6de | []
| no_license | angrygoat/DE | 404713babd3c80a25751a3f878c1a0a6c4195d43 | c561c97011f11af7dd6055fded7652b41e1ad789 | refs/heads/unc-master | 2020-04-05T23:04:18.936071 | 2016-11-29T18:51:13 | 2016-11-29T18:51:13 | 60,772,000 | 2 | 0 | null | 2016-10-11T17:29:27 | 2016-06-09T12:09:05 | Java | UTF-8 | Java | false | false | 1,720 | java | package org.iplantc.de.analysis.client.events;
import org.iplantc.de.client.models.IsHideable;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;
/**
* @author jstroot
*/
public class SaveAnalysisParametersEvent extends GwtEvent<SaveAnalysisParametersEvent.SaveAnalysisParametersEventHandler> {
public interface SaveAnalysisParametersEventHandler extends EventHandler {
void onRequestSaveAnalysisParameters(SaveAnalysisParametersEvent event);
}
public static interface HasSaveAnalysisParametersEventHandlers {
HandlerRegistration addSaveAnalysisParametersEventHandler(SaveAnalysisParametersEventHandler handler);
}
public static final Type<SaveAnalysisParametersEventHandler> TYPE = new Type<>();
private final String path;
private final String fileContents;
private final IsHideable hideable;
public SaveAnalysisParametersEvent(final String path,
final String fileContents,
final IsHideable hideable) {
this.path = path;
this.fileContents = fileContents;
this.hideable = hideable;
}
@Override
public Type<SaveAnalysisParametersEventHandler> getAssociatedType() {
return TYPE;
}
public String getFileContents() {
return fileContents;
}
public String getPath() {
return path;
}
public IsHideable getHideable() {
return hideable;
}
@Override
protected void dispatch(SaveAnalysisParametersEventHandler handler) {
handler.onRequestSaveAnalysisParameters(this);
}
}
| [
"[email protected]"
]
| |
8f110756b0b3cbbebe4f0181aa0f35ec5b61f8ca | ec9a8e31c623e861029f5aac3498d5f08c216fee | /src/rmdraw/apptools/SGLineTool.java | 780f7dafeb4bf77e612ea82c46bef3de19ae0e4c | []
| no_license | reportmill/RMDraw | 6a0e27c98c6ff4357e7277ad0a694b8666c8adc8 | 7aa7f4af4935e3a70fc009b2341fd8ef3514dee1 | refs/heads/master | 2023-04-19T07:58:20.247962 | 2023-04-17T14:55:04 | 2023-04-17T14:55:04 | 236,824,424 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,902 | java | /*
* Copyright (c) 2010, ReportMill Software. All rights reserved.
*/
package rmdraw.apptools;
import rmdraw.app.Tool;
import rmdraw.scene.*;
import java.util.*;
import snap.geom.Point;
import snap.gfx.*;
import snap.util.SnapUtils;
import snap.view.*;
import snap.web.WebURL;
/**
* This class handles creation of lines.
*/
public class SGLineTool<T extends SGLine> extends Tool<T> {
// Indicates whether line should try to be strictly horizontal or vertical
private boolean _hysteresis = false;
// The list of arrow heads
private static SGView _arrowHeads[];
// Constants for line segment points
public static final byte HandleStartPoint = 0;
public static final byte HandleEndPoint = 1;
/**
* Returns the view class that this tool is responsible for.
*/
public Class getViewClass()
{
return SGLine.class;
}
/**
* Returns the name of this tool to be displayed by inspector.
*/
public String getWindowTitle()
{
return "Line Inspector";
}
/**
* Event handling - overridden to install cross-hair cursor.
*/
public void mouseMoved(ViewEvent anEvent)
{
getEditor().setCursor(Cursor.CROSSHAIR);
}
/**
* Handles mouse press for line creation.
*/
public void mousePressed(ViewEvent anEvent)
{
super.mousePressed(anEvent);
_hysteresis = true;
}
/**
* Handles mouse drag for line creation.
*/
public void mouseDragged(ViewEvent anEvent)
{
Point currentPoint = getEditorEvents().getEventPointInView(true);
double dx = currentPoint.getX() - _downPoint.getX();
double dy = currentPoint.getY() - _downPoint.getY();
double breakingPoint = 20f;
if (_hysteresis) {
if (Math.abs(dx) > Math.abs(dy)) {
if (Math.abs(dy) < breakingPoint) dy = 0;
else _hysteresis = false;
}
else if (Math.abs(dx) < breakingPoint) dx = 0;
else _hysteresis = false;
}
// Register for repaint
_newView.repaint();
// Set adjusted bounds
_newView.setBounds(_downPoint.getX(), _downPoint.getY(), dx, dy);
}
/**
* Editor method (returns the number of handles).
*/
public int getHandleCount(T aView)
{
return 2;
}
/**
* Editor method.
*/
public Point getHandlePoint(T aView, int anIndex, boolean isSuperSel)
{
return super.getHandlePoint(aView, anIndex == HandleEndPoint ? HandleSE : anIndex, isSuperSel);
}
/**
* Editor method.
*/
public void moveHandle(T aView, int aHandle, Point aPoint)
{
super.moveHandle(aView, aHandle == HandleEndPoint ? HandleSE : aHandle, aPoint);
}
/**
* Loads the list of arrows from a .rpt file.
*/
private SGView[] getArrowHeads()
{
// If already set, just return
if (_arrowHeads != null) return _arrowHeads;
// Load document with defined arrow heads
WebURL url = WebURL.getURL(SGLineTool.class, "SGLineToolArrowHeads.rpt");
SGDoc doc = SGDoc.getDocFromSource(url);
// Extract lines and heads and return array of heads
List<SGLine> lines = doc.getChildrenWithClass(SGLine.class);
List<SGView> heads = new ArrayList(lines.size());
for (SGLine ln : lines) heads.add(ln.getArrowHead());
return _arrowHeads = heads.toArray(new SGView[lines.size()]);
}
/**
* Initialize UI panel.
*/
protected void initUI()
{
// Get arrows menu button
MenuButton menuButton = getView("ArrowsMenuButton", MenuButton.class);
// Add arrows menu button
SGView arrowHeads[] = getArrowHeads();
for (int i = 0; i < arrowHeads.length; i++) {
SGView ahead = arrowHeads[i];
Image image = SGViewUtils.createImage(ahead, null);
MenuItem mi = new MenuItem();
mi.setImage(image);
mi.setName("ArrowsMenuButtonMenuItem" + i);
menuButton.addItem(mi);
}
// Add "None" menu item
MenuItem mi = new MenuItem();
mi.setText("None");
mi.setName("ArrowsMenuButtonMenuItem 999");
menuButton.addItem(mi);
}
/**
* Update UI panel.
*/
public void resetUI()
{
// Get selected line and arrow head
SGLine line = getSelView();
if (line == null) return;
SGLine.ArrowHead ahead = line.getArrowHead();
// Update ArrowsMenuButton
Image image = ahead != null ? SGViewUtils.createImage(line.getArrowHead(), null) : null;
getView("ArrowsMenuButton", MenuButton.class).setImage(image);
// Update ScaleText and ScaleThumbWheel
setViewValue("ScaleText", ahead != null ? ahead.getScaleX() : 0);
setViewValue("ScaleThumbWheel", ahead != null ? ahead.getScaleX() : 0);
setViewEnabled("ScaleText", ahead != null);
setViewEnabled("ScaleThumbWheel", ahead != null);
}
/**
* Respond to UI change.
*/
public void respondUI(ViewEvent anEvent)
{
// Get selected line and arrow head
SGLine line = getSelView();
SGLine.ArrowHead arrowHead = line.getArrowHead();
// Handle ScaleText and ScaleThumbWheel
if (anEvent.equals("ScaleText") || anEvent.equals("ScaleThumbWheel"))
arrowHead.setScaleXY(anEvent.getFloatValue(), anEvent.getFloatValue());
// Handle ArrowsMenuButtonMenuItem
if (anEvent.getName().startsWith("ArrowsMenuButtonMenuItem")) {
int ind = SnapUtils.intValue(anEvent.getName());
SGView ahead = ind < getArrowHeads().length ? getArrowHeads()[ind] : null;
line.setArrowHead(ahead != null ? (SGLine.ArrowHead) ahead.clone() : null);
}
}
} | [
"[email protected]"
]
| |
25fe4c4db4a6a078848118011126f5b31afe9a06 | c9cf73543d7c81f8e87a58e051380e98e92f978a | /baseline/happy_trader/platform/client/clientHT/clientUI/src/com/fin/httrader/webserver/HtHTTPCommandGateway.java | 5ef36f460eb68022e75b861e06f313e6f95ec81a | []
| no_license | vit2000005/happy_trader | 0802d38b49d5313c09f79ee88407806778cb4623 | 471e9ca4a89db1b094e477d383c12edfff91d9d8 | refs/heads/master | 2021-01-01T19:46:10.038753 | 2015-08-23T10:29:57 | 2015-08-23T10:29:57 | 41,203,190 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 6,113 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.fin.httrader.webserver;
import com.fin.httrader.interfaces.HtEventListener;
import com.fin.httrader.managers.RtConfigurationManager;
import com.fin.httrader.managers.RtGlobalEventManager;
import com.fin.httrader.model.HtCommandProcessor;
import com.fin.httrader.utils.HtException;
import com.fin.httrader.utils.HtLog;
import com.fin.httrader.utils.HtTimeCalculator;
import com.fin.httrader.utils.HtUtils;
import com.fin.httrader.utils.LongParam;
import com.fin.httrader.utils.SingleReaderQueue;
import com.fin.httrader.utils.SingleReaderQueueExceedLimit;
import com.fin.httrader.utils.Uid;
import com.fin.httrader.utils.hlpstruct.XmlEvent;
import com.fin.httrader.utils.hlpstruct.XmlHandler;
import com.fin.httrader.utils.hlpstruct.XmlParameter;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.logging.Level;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
/**
*
* @author Victor_Zoubok
*/
public class HtHTTPCommandGateway extends HtServletsBase {
@Override
public String getContext() {
return this.getClass().getSimpleName();
}
@Override
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
throw new ServletException("GET not supported");
}
@Override
public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
res.setContentType("text/xml; charset=UTF-8");
forceNoCache(res);
final HtAjaxCaller ajaxCaller = new HtAjaxCaller();
ajaxCaller.setOk();
String sessionId = null;
try {
// cehck user session
String user = this.getStringParameter(req, "user", false);
String hashed_password = this.getStringParameter(req, "hashed_password", false);
String userIp = req.getRemoteHost();
checkCredentials(user, hashed_password);
String content = getStringParameter(req, "content", false);
XmlParameter request_param = XmlHandler.deserializeParameterStatic(content);
String command_data = request_param.getString("command_data");
String event_name = request_param.getString("event_name");
String command_name = request_param.getString("command_name");
String non_blocking_s = request_param.getString("non_blocking");
boolean non_blocking = non_blocking_s.equalsIgnoreCase("true");
final int tout_sec = HtUtils.parseInt(request_param.getString("tout_sec"));
// create event
XmlEvent xmlevent = new XmlEvent();
xmlevent.setEventType(XmlEvent.ET_CustomEvent);
xmlevent.setType(XmlEvent.DT_CommonXml);
xmlevent.getAsXmlParameter().setCommandName(event_name);
xmlevent.getAsXmlParameter().setString("command", command_name);
xmlevent.getAsXmlParameter().setString("command_data", command_data);
xmlevent.getAsXmlParameter().setInt("non_blocking", non_blocking ? 1 : 0);
xmlevent.getAsXmlParameter().setInt("tout_sec", tout_sec);
// blocking - must spawn the thread and wait for a result
final SingleReaderQueue arrived = new SingleReaderQueue("HTTPCommandGateway event queue", false, RtConfigurationManager.StartUpConst.MAX_ELEMENTS_IN_QUEUE);
final LongParam success = new LongParam(-1);
final ArrayList list = new ArrayList();
//
HtEventListener eventReceiver = new HtEventListener() {
@Override
public void onEventArrived(XmlEvent event) throws SingleReaderQueueExceedLimit {
if (event.getEventType() == XmlEvent.ET_CustomEvent) {
if (event.getType() == XmlEvent.DT_CommonXml) {
XmlParameter xml_param = event.getAsXmlParameter();
String custom_event_name = xml_param.getCommandName();
if (custom_event_name != null) {
if (custom_event_name.equals("custom_alg_event_return_result")) {
// ours
arrived.put(event);
}
}
}
}
}
@Override
public String getListenerName() {
return "listener: [HTTPCommandGateway event listener]";
}
};
RtGlobalEventManager.instance().resolveListenerThread(RtGlobalEventManager.instance().MAIN_THREAD).subscribeForEvent(XmlEvent.ET_CustomEvent, 5008, eventReceiver);
Thread runnable = new Thread() {
@Override
public void run() {
boolean to_stop = false;
HtTimeCalculator tcalc = new HtTimeCalculator();
while (true) {
if (to_stop) {
break;
}
// wait 1 sec
arrived.get(list, 1000);
for (Iterator it = list.iterator(); it.hasNext();) {
XmlEvent returned = (XmlEvent) it.next();
if (returned != null) {
ajaxCaller.setData(returned.getAsXmlParameter().getString("out"));
to_stop = true;
}
}
if (tcalc.elapsed() > tout_sec * 1000) {
break;
}
} // end loop
if (to_stop) {
// success
success.setLong(0);
}
}
};
runnable.start();
// push event
// this event must go through HtAlgorithmRequstBroker
// and then return response here
RtGlobalEventManager.instance().pushCommonEvent(xmlevent);
runnable.join();
RtGlobalEventManager.instance().resolveListenerThread(RtGlobalEventManager.instance().MAIN_THREAD).unsubscribeForAllEvents(eventReceiver);
if (success.getLong() == -1) {
throw new HtException(getContext(), "doPost", "Timeout exceeded its value when trying to get results");
}
} catch (Throwable e) {
ajaxCaller.setError(-1, e.getMessage());
}
ajaxCaller.serializeToXml(res);
}
/**
* Helpers
*/
private void checkCredentials(String user, String hashed_password) throws Exception {
boolean res = HtCommandProcessor.instance().get_HtSecurityProxy().remote_checkUserCredentialsWithHashedPassword(user, hashed_password);
if (!res) {
throw new HtException(getContext(), "initialize", "Invalid user or password");
}
}
}
| [
"[email protected]"
]
| |
aea3bf2f6c4af2d30f666299d671c330a1eca7c6 | 1b9ccc6f1c7320b6160d43146242192d0f54499f | /heima-leadnews/heima-leadnews-wemedia/src/main/java/com/heima/wemedia/controller/LoginController.java | 0106200e649d85f0852285f333a4838dbd474a81 | []
| no_license | xlaity/leadnews | c61adc5ff83f5f784236be7d62cbe381cbd2955a | ff5b485ed62fa7d04cf01f12623d4671d4c82e6a | refs/heads/master | 2023-07-12T08:56:42.679156 | 2021-08-19T09:18:47 | 2021-08-19T09:18:47 | 397,841,803 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 881 | java | package com.heima.wemedia.controller;
import com.heima.common.dtos.Result;
import com.heima.model.admin.pojos.AdUser;
import com.heima.model.wemedia.pojos.WmUser;
import com.heima.wemedia.service.WmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* 自媒体人登录
*/
@RestController
@RequestMapping("/login")
public class LoginController {
@Autowired
private WmUserService wmUserService;
/**
* 登录
*/
@PostMapping("/in")
public Result<Map<String,Object>> login(@RequestBody WmUser user){
return wmUserService.login(user);
}
}
| [
"[email protected]"
]
| |
5b98284168b22488ef74c62f10232d6fcb566027 | 6d7108b8411cd92bd8598d3752582531c36ead67 | /octarine-functional/src/main/java/com/codepoetics/octarine/functional/tuples/T2.java | efc3c92df31cf97d8010f784bd9aa95657df4c78 | [
"Apache-2.0"
]
| permissive | j4d/octarine | 89cb16964aaffad1a3cd04f690549f6644cd8b5d | 972f6c328d61f40b30844a3deac83d60f81e7c9a | refs/heads/master | 2023-04-11T06:49:13.990796 | 2021-04-21T15:56:39 | 2021-04-21T15:56:46 | 360,223,716 | 0 | 0 | Apache-2.0 | 2021-04-21T15:44:02 | 2021-04-21T15:44:00 | null | UTF-8 | Java | false | false | 2,144 | java | package com.codepoetics.octarine.functional.tuples;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Function;
public final class T2<A, B> {
private final A a;
private final B b;
private T2(A a, B b) {
this.a = a;
this.b = b;
}
public static <S, A, B> Function<S, T2<A, B>> unpacker(Function<? super S, ? extends A> first,
Function<? super S, ? extends B> second) {
return s -> T2.of(first.apply(s), second.apply(s));
}
public static <A, B> TupleLens<T2<A, B>, A> first() {
return TupleLens.of(
0,
T2::getFirst,
T2::withFirst
);
}
public static <A, B> TupleLens<T2<A, B>, B> second() {
return TupleLens.of(
1,
T2::getSecond,
T2::withSecond
);
}
public static <A, B> T2<A, B> of(A a, B b) {
return new T2<>(a, b);
}
public A getFirst() {
return a;
}
public <A2> T2<A2, B> withFirst(A2 a2) {
return T2.of(a2, b);
}
public B getSecond() {
return b;
}
public <B2> T2<A, B2> withSecond(B2 b2) {
return T2.of(a, b2);
}
public <R> R pack(BiFunction<? super A, ? super B, ? extends R> f) {
return f.apply(a, b);
}
public <C> T3<A, B, C> push(C c) {
return Tuple.of(a, b, c);
}
public T2<B, T1<A>> pop() {
return Tuple.of(b, Tuple.of(a));
}
public T2<A, T1<B>> shift() {
return Tuple.of(a, Tuple.of(b));
}
public T2<B, A> swap() {
return T2.of(b, a);
}
@Override
public boolean equals(Object o) {
if (!(o instanceof T2)) {
return false;
}
T2 other = (T2) o;
return Objects.equals(a, other.a) &&
Objects.equals(b, other.b);
}
@Override
public int hashCode() {
return Objects.hash(a, b);
}
@Override
public String toString() {
return String.format("(%s, %s)", a, b);
}
}
| [
"[email protected]"
]
| |
7eed6e71bf3fdaabd6eedcbbc7aa7e83ee94e1a1 | 3a5270270ccacf4e6845723f25dd0bb84f9f683f | /app/src/main/java/com/qingpeng/mz/views/AliyunScreenMode.java | 9d30ddf9bf91eb136f6bdff1ee0f2ecf976c2ece | []
| no_license | QPKJEDL/LiveApp | 8ed427472b08d8f274f48c7202cfb7667a314987 | 8951895fbcde2110d45d52a14797222fd8912d44 | refs/heads/master | 2022-11-19T16:11:58.385288 | 2020-07-24T02:07:12 | 2020-07-24T02:07:12 | 282,088,487 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 260 | java | package com.qingpeng.mz.views;
/*
* Copyright (C) 2010-2018 Alibaba Group Holding Limited.
*/
/**
* UI 全屏和小屏模式
*/
public enum AliyunScreenMode {
/**
* 小屏模式
*/
Small,
/**
* 全屏模式
*/
Full
}
| [
"[email protected]"
]
| |
2dd5375a375319fe98c00aa8178087fc299031bb | 5afc1e039d0c7e0e98216fa265829ce2168100fd | /his-statistics/src/main/java/cn/honry/statistics/bi/operation/operatioNum/vo/OperationNum2Vo.java | 55f0653230b9c1e18b242747397b12ca74ab9d01 | []
| no_license | konglinghai123/his | 66dc0c1ecbde6427e70b8c1087cddf60f670090d | 3dc3eb064819cb36ce4185f086b25828bb4bcc67 | refs/heads/master | 2022-01-02T17:05:27.239076 | 2018-03-02T04:16:41 | 2018-03-02T04:16:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 400 | java | package cn.honry.statistics.bi.operation.operatioNum.vo;
public class OperationNum2Vo {
private Integer opNum;
private String scale;
public Integer getOpNum() {
return opNum;
}
public void setOpNum(Integer opNum) {
this.opNum = opNum;
}
public String getScale() {
return scale;
}
public void setScale(String scale) {
this.scale = scale;
}
}
| [
"[email protected]"
]
| |
174b8a485ca459d8c9f4ddb1942b17b14f25b1f9 | b48282caa22f85fa29f1415b98282c6d471feb34 | /src/main/java/gps/globalobjects/DoubleSumGlobalObject.java | 3215a9521db380cd153d2e0f5a094e28f272066e | []
| no_license | MBtech/gps | 7f50f49e4262a798d9d54bd2fae91860637fd474 | f916e1e04c940e577713c219b6a5ed8224838417 | refs/heads/master | 2020-04-26T06:55:44.014185 | 2019-03-01T23:13:23 | 2019-03-01T23:13:23 | 173,380,085 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 443 | java | package gps.globalobjects;
import gps.writable.DoubleWritable;
import gps.writable.MinaWritable;
public class DoubleSumGlobalObject extends DoubleGlobalObject {
public DoubleSumGlobalObject() {
super();
}
public DoubleSumGlobalObject(double value) {
super(value);
}
@Override
public void update(MinaWritable otherValue) {
setValue(new DoubleWritable(getValue().getValue() +
((DoubleWritable) otherValue).getValue()));
}
}
| [
"[email protected]"
]
| |
3543cad76a71b254733bc38a98829936b9cca99f | d47a763c789a36fc1cd6f43ba0493342d69c530d | /mina-protobuf-runtime/src/main/java/com/weijiangzhu/minaserver/message/Message.java | e860b72d66b555b74318e2404e962ce60eb4a3cd | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-protobuf"
]
| permissive | weijiangzhu/mina | a50e8722b686e7414de19385b85c3714e97f16cb | fa32b3de19462df639a78aafbcfa5ff141a2c329 | refs/heads/trunk | 2021-01-16T22:59:13.386420 | 2015-09-21T02:06:22 | 2015-09-21T02:06:22 | 42,578,437 | 0 | 0 | null | 2015-09-16T09:42:14 | 2015-09-16T09:42:14 | null | UTF-8 | Java | false | false | 411 | java | package com.weijiangzhu.minaserver.message;
public class Message {
private Integer msgType;
private Object body;
public Message(Integer msgType, Object body) {
this.msgType = msgType;
this.body = body;
}
public Object getBody() {
return body;
}
public Integer getMsgType() {
return msgType;
}
public void setMsgType(Integer msgType) {
this.msgType = msgType;
}
}
| [
"[email protected]"
]
| |
4a8a80d114654cff3ca5f022ff9b3cf2e845239c | e49ddf6e23535806c59ea175b2f7aa4f1fb7b585 | /tags/release-2.5/mipav/src/gov/nih/mipav/model/algorithms/AlgorithmSkeletonize3D.java | 7f7ec7fede6612983a55bf95116d8cb8f54542c4 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | svn2github/mipav | ebf07acb6096dff8c7eb4714cdfb7ba1dcace76f | eb76cf7dc633d10f92a62a595e4ba12a5023d922 | refs/heads/master | 2023-09-03T12:21:28.568695 | 2019-01-18T23:13:53 | 2019-01-18T23:13:53 | 130,295,718 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 150,044 | java | package gov.nih.mipav.model.algorithms;
import gov.nih.mipav.model.file.*;
import gov.nih.mipav.model.structures.*;
import gov.nih.mipav.model.structures.jama.*;
import gov.nih.mipav.view.*;
import java.awt.*;
import java.io.*;
/**
* This is a port of the C++ code for pfSkel: Potential Field Based 3D Skeleton Extraction written by Nicu D. Cornea,
* Electrical and Computer Engineering Department, Rutgers, The State University of New Jersey, Piscataway, New Jersey,
* 08854, [email protected]. The code was downloaded from http://www.caip.rutgers.edu/~cornea/Skeletonization/
* References: 1.) Jen-Hui Chuang, Chi-Hao Tsai, Min-Chi Ko, Skeletonization of Three-Dimensional Object Using
* Generalized Potential Field, IEEE Transactions on Pattern Analysis and Machine Intelligence, Vol. 22., No. 11,
* November, 2000, pp. 1241-1251. 2.) Nicu D. Cornea, Deborah Silver, and Patrick Min, Curve-Skeleton Applications,
* Proceedings IEEE Visualization, 2005, pp. 95-102. 3.) Nicu D. Cornea, Deborah Silver, Xiaosong Yuan, and Raman
* Balasubramanian, Computing Hierarchical Curve-Skeletons of 3D Objects, Springer-Verlag, The Visual Computer, Vol. 21,
* No. 11, October, 2005, pp. 945-955. To run this program on an image there must be a sufficient number of planes
* composed solely of background pixels at the end x, y, and z boundaries of the image. For the default value of 0 for
* the distance of the electrical charges from the object boundary, there must be background planes at x = 0, x = xDim -
* 1, y = 0, y = yDim - 1, z = 0, and z = zDim - 1. Use the utilities Add image margins or Insert slice to create a
* version of the image with the needed number of padding pixels. 98% of the image calculation time will be in the
* potential field calculation. So the first time this program is run on an image select the save the vector fields
* radio button to save the x, y, and z vector fields and the level 1 skeleton. On the following runs select the load
* the vector field from files radio button to load the x, y, and z vector fields and the level 1 skeleton. On following
* runs vary the entry fraction of divergence points to use to change the extensiveness of the skeleton generated. As
* more divergence points are used in the level 2 skeleton calculation, the skeleton will become more extensive. The
* program must be run on 1 solid object. For that new features have been added to the original program. A user selected
* threshold will separate background from object voxels. A default selected checkbox for slice by slice hole filling
* will be used to convert the image into 1 solid object. After IDing all the objects in 3D, all but the largest object
* will be deleted.
*/
public class AlgorithmSkeletonize3D extends AlgorithmBase {
//~ Static fields/initializers -------------------------------------------------------------------------------------
/** DOCUMENT ME! */
private static final byte OBJECT_VAL = 1;
/** 3 values defining outside pixels. */
private static final byte OUTSIDE_1 = 2;
/** DOCUMENT ME! */
private static final byte OUTSIDE_2 = 3;
/** DOCUMENT ME! */
private static final byte OUTSIDE_3 = 4;
/** interior voxel. */
private static final byte INTERIOR = 70;
/** background (exterior to the object) voxel. */
private static final byte EXTERIOR = 0;
/** surface voxel. */
private static final byte SURF = 50;
/** Boundary voxel - participates in potential field calculation. */
private static final byte BOUNDARY = 60;
/** Added voxels in order to thicken the object. */
private static final byte PADDING_MIN = 80;
/** DOCUMENT ME! */
private static final int BOUND_SIZE = 1200000;
/**
* If a boundary point is at a distance greater than the PF_THRESHOLD, then it is ignored, i.e., it does not
* influence the field at this point. Setting this to a very low value is not a good idea: Imagine the example of a
* very long cylinder. Setting this threshold smaller than half the length of the cylinder will cause the field not
* to flow towards the one attracting point in the middle of the cylinder. Instead it will only go towards the
* center, creating a critical point at each slice along the cylinder.
*/
private static final short PF_THRESHOLD = 100;
/** DOCUMENT ME! */
private static final int MAX_NUM_CRITPTS = 2000;
/** DOCUMENT ME! */
private static final double EPSILON = 1.0E-6;
/** DOCUMENT ME! */
private static final int NR_OF_SIGN_CHANGES = 3;
/** DOCUMENT ME! */
private static final double CELL_SUBDIVISION_FACTOR = 1048576.0;
/** DOCUMENT ME! */
private static final byte CPT_SADDLE = 1;
/** DOCUMENT ME! */
private static final byte CPT_ATTRACTING_NODE = 2;
/** DOCUMENT ME! */
private static final byte CPT_REPELLING_NODE = 3;
/** DOCUMENT ME! */
private static final byte CPT_UNKNOWN = 4;
/** Exit status in followStreamLines. */
private static final int FSL_EXS_ERROR = 0;
/** DOCUMENT ME! */
private static final int FSL_EXS_TOO_MANY_STEPS = 1;
/** DOCUMENT ME! */
private static final int FSL_EXS_CLOSE_TO_SKEL = 2;
/** DOCUMENT ME! */
private static final int FSL_EXS_CLOSE_TO_CP = 3;
/** DOCUMENT ME! */
private static final int FSL_EXS_STUCK = 4;
/** DOCUMENT ME! */
private static final int FSL_EXS_OUTSIDE = 5;
/** left end point of the segment. */
private static final int SKEL_SEG_LEFT = 0;
/** right end point of the segment. */
private static final int SKEL_SEG_RIGHT = 1;
/** first point of the segment excluding the left end point. */
private static final int SKEL_SEG_FIRST = 2;
/** last point of the segment excluding the right end point. */
private static final int SKEL_SEG_LAST = 3;
/**
* At each ... th step, we check whether we made some progress in the last ... steps (some more points were added to
* the skeleton). If yes, we go on for another ... steps. If not, we stop.
*/
private static final int PROGRESS_CHECK_INTERVAL = 1000;
/**
* Once we make MAX_NUM_STEP_INTERVALS * PROGRESS_STEP_INTERVAL, we should stop following the vector field. We are
* probably stuck near an attracting node.
*/
private static final int MAX_NUM_STEP_INTERVALS = 50;
/**
* Defines the maximum number of skeleton points that can separate an intersection with a skeleton segment from the
* segment's end points so that the intersection is not reported. When constructing a skeleton segment, at each step
* we test for intersection with other existing segments. If we are close to another skeleton segment, we also check
* if we are also close to one of that segment's end points. If we are, we keep going even if the points in the 2
* segments overlap, in the hope that we can end the current segment at the same point as the segment we are
* intersecting, thus reducing the number of joints. Of course this does not work if we are close to an end point
* but we are actually moving towards the other end of the segment, but in that case, the current segment will be
* terminated once we get far enough from the end point.
*/
private static final int SP_CLOSE_TO_SEGMENT_ENDPOINT = 5;
/** Defines "close to ..." in terms of Manhattan distance |x1-x2| + |y1-y2| + |z1-z2|. */
private static final double SP_SMALL_DISTANCE = 0.5;
/**
* This is the size of the step used to advance to the next position when following the vector field. 0.2 seems to
* be the best value
*/
private static final double STEP_SIZE = 0.2;
/**
* Minimum segment length (number of points) Only segments containing at least that many points will be included in
* the skeleton. However, if the segment originated in a critical point, we should keep it regardless of the length.
* Removing it, might disconnect the basic skeleton.
*/
private static final int MIN_SEG_LENGTH = 5;
/** DOCUMENT ME! */
private static final int MAX_NUM_HDPTS = 5000;
/** DOCUMENT ME! */
private static final int SEARCH_GRID = 1;
/** DOCUMENT ME! */
private static final double CELL_SIZE = 1.00 / SEARCH_GRID;
//~ Instance fields ------------------------------------------------------------------------------------------------
/** coordinates of critical points. */
private double[][] critPts = null;
/**
* distCharges and fieldStrength are unused if field vectors and the level 1 skeleton are read in from files
* distance of electric charges from object boundary -40 to 40.
*/
private int distCharges = 0;
/** 3 eigenvectors of the Jacobian matrix evaluateed at the critical point (3 double values for each vector). */
private double[][][] eigenvectors = null;
/** electric field strenth (4-9). */
private int fieldStrength = 5;
/** x component of vector field. */
private double[] forceX = null;
/** y component of vector field. */
private double[] forceY = null;
/** z component of vector field. */
private double[] forceZ = null;
/** DOCUMENT ME! */
private double[][] hdPoints = null;
/** Minimum value for outer pixel to be an object pixel. */
private float minObjectValue;
/** number of critical points. */
private int numCritPoints = 0;
/** DOCUMENT ME! */
private int numHDPoints = 0;
/** If true, output all skeleton points If false, output only end points of segments. */
private boolean outputPoints = true;
/** fraction of the highest negative divergence points to use. */
private float perHDPoints = 0.3f;
/** type of critical point (1 - saddle point, 2 - attracting node, 3 - repelling point, 4 - unknown). */
private byte[] pointType = null;
/** real part of 3 eigenvalues of Jacobian matrix evaluated at the critical point. */
private double[][] realEigenvalues = null;
/** If true save the x, y, and z vector components and the level 1 skeleton. */
private boolean saveVF = true;
/** DOCUMENT ME! */
private int skelNumPoints = 0;
/** DOCUMENT ME! */
private int skelNumSegments = 0;
/** DOCUMENT ME! */
private double[][] skelPoints = null;
/** DOCUMENT ME! */
private int[][] skelSegments = null;
/** DOCUMENT ME! */
private int skelSizePoints = 0;
/** DOCUMENT ME! */
private int skelSizeSegments = 0;
/** skeleton points written to or read from file. */
private double[][] skPoints = null;
/** skeleton segments written to or read from file. */
private int[][] skSegments = null;
/** If true, perform slice by slice hole filling on the thresholded image. */
private boolean sliceHoleFilling = true;
/** DOCUMENT ME! */
private int sliceSize;
/** DOCUMENT ME! */
private ModelImage solidImage = null;
/** DOCUMENT ME! */
private int totLength;
/** DOCUMENT ME! */
private byte[] vol;
/** DOCUMENT ME! */
private float[] volFloat;
/** DOCUMENT ME! */
private int xDim;
/** DOCUMENT ME! */
private int yDim;
/** DOCUMENT ME! */
private int zDim;
//~ Constructors ---------------------------------------------------------------------------------------------------
/**
* Constructor for putting a 3D skeleton into the source image.
*
* @param srcImg the source image.
* @param minObjectValue minimum value for outer pixel to be an object pixel
* @param sliceHoleFilling If true, perform slice by slice hole filling on the segmented
* @param saveVF if true save xvf, yvf, zvf, and skf files
* @param distCharges distance of electrical charges from object boundary
* @param fieldStrength field strength (4-9)
* @param perHDPoints fraction of divergence points to use (0.0 - 1.0)
* @param forceX x component of vector field
* @param forceY y component of vector field
* @param forceZ z component of vector field
* @param skPoints skeleton points read from a file
* @param skSegments skeleton segments read from a file
* @param outputPoints If true, output all skeleton points If false, output only end points of segments
*/
public AlgorithmSkeletonize3D(ModelImage srcImg, float minObjectValue, boolean sliceHoleFilling, boolean saveVF,
int distCharges, int fieldStrength, float perHDPoints, double[] forceX,
double[] forceY, double[] forceZ, double[][] skPoints, int[][] skSegments,
boolean outputPoints) {
super(null, srcImg);
this.minObjectValue = minObjectValue;
this.sliceHoleFilling = sliceHoleFilling;
this.saveVF = saveVF;
this.distCharges = distCharges;
this.fieldStrength = fieldStrength;
this.perHDPoints = perHDPoints;
this.forceX = forceX;
this.forceY = forceY;
this.forceZ = forceZ;
this.skPoints = skPoints;
this.skSegments = skSegments;
this.outputPoints = outputPoints;
}
//~ Methods --------------------------------------------------------------------------------------------------------
/**
* DOCUMENT ME!
*/
public void runAlgorithm() {
int i, j, k;
ModelImage gvfImage;
boolean[] used;
float[] xArr = new float[1];
float[] yArr = new float[1];
float[] zArr = new float[1];
VOI newPtVOI;
short ptNum;
short segNum;
boolean haveSegColor;
Color segColor = null;
int[] extents2D;
byte[] buffer2D;
ModelImage grayImage2D;
FileInfoBase fileInfo;
boolean wholeImage = true;
int z;
AlgorithmMorphology2D fillHolesAlgo2D;
int kernel;
float sphereDiameter;
int method;
int itersDilation;
int itersErosion;
int numPruningPixels;
int edgingType;
AlgorithmMorphology3D idObjectsAlgo3D;
int numObjects;
ModelImage idImage;
int[] idArray;
int[] idCount;
int maxCount;
int maxID;
/*int test = 1;
* if (test == 1) { createCylinder(); setCompleted(true); return;}*/
constructLog();
buildProgressBar(srcImage.getImageName(), "Performing 3D skeletonization...", 0, 100);
initProgressBar();
xDim = srcImage.getExtents()[0];
yDim = srcImage.getExtents()[1];
zDim = srcImage.getExtents()[2];
sliceSize = xDim * yDim;
totLength = sliceSize * zDim;
File file;
RandomAccessFile raFile;
volFloat = new float[totLength];
try {
srcImage.exportData(0, totLength, volFloat);
} catch (IOException e) {
MipavUtil.displayError("IO error on srcImage.exportData");
disposeProgressBar();
setCompleted(false);
return;
}
if (skPoints == null) {
if (!checkVolumePadding()) {
MipavUtil.displayError("Error! The object is not sufficiently padded");
disposeProgressBar();
setCompleted(false);
return;
}
} // if (skPoints == null)
progressBar.setMessage("Making volume solid");
Preferences.debug("Making volume solid\n");
makeSolidVolume();
/*boolean test;
* test = false; if (test) { solidImage = new ModelImage(ModelStorageBase.BYTE, srcImage.getExtents(),
* "solidImage", srcImage.getUserInterface()); try { solidImage.importData(0, vol, true);
* } catch (IOException e) { MipavUtil.displayError("IOException on soldImage.importData");
* disposeProgressBar(); setCompleted(false); return; }
*
* new ViewJFrameImage(solidImage); progressBar.dispose(); setCompleted(true); return;} // if (test)*/
if (sliceHoleFilling) {
progressBar.setMessage("Slice by slice hole filling");
Preferences.debug("Slice by slice hole filling\n");
extents2D = new int[2];
extents2D[0] = srcImage.getExtents()[0];
extents2D[1] = srcImage.getExtents()[1];
buffer2D = new byte[sliceSize];
grayImage2D = new ModelImage(ModelStorageBase.USHORT, extents2D, srcImage.getImageName() + "_gray2D",
srcImage.getUserInterface());
fileInfo = grayImage2D.getFileInfo()[0];
fileInfo.setResolutions(srcImage.getFileInfo()[0].getResolutions());
fileInfo.setUnitsOfMeasure(srcImage.getFileInfo()[0].getUnitsOfMeasure());
grayImage2D.setFileInfo(fileInfo, 0);
for (z = 0; z < zDim; z++) {
for (i = 0; i < sliceSize; i++) {
buffer2D[i] = vol[(z * sliceSize) + i];
}
try {
grayImage2D.importData(0, buffer2D, true);
} catch (IOException e) {
MipavUtil.displayError("Error on grayImage2D importData");
progressBar.dispose();
setCompleted(false);
return;
}
fillHolesAlgo2D = new AlgorithmMorphology2D(grayImage2D, 0, 0, AlgorithmMorphology2D.FILL_HOLES, 0, 0,
0, 0, wholeImage);
fillHolesAlgo2D.setProgressBarVisible(false);
fillHolesAlgo2D.run();
fillHolesAlgo2D.finalize();
fillHolesAlgo2D = null;
try {
grayImage2D.exportData(0, sliceSize, buffer2D);
} catch (IOException e) {
MipavUtil.displayError("Error on grayImage2D exportData");
progressBar.dispose();
setCompleted(false);
return;
}
for (i = 0; i < sliceSize; i++) {
vol[(z * sliceSize) + i] = buffer2D[i];
}
} // for (z = 0; z < zDim; z++)
grayImage2D.disposeLocal();
grayImage2D = null;
buffer2D = null;
} // if (sliceHoleFilling)
progressBar.setMessage("Delete all but the largest object\n");
Preferences.debug("Delete all but the largest object\n");
idImage = new ModelImage(ModelStorageBase.USHORT, srcImage.getExtents(), srcImage.getImageName() + "_id",
srcImage.getUserInterface());
try {
idImage.importData(0, vol, true);
} catch (IOException e) {
MipavUtil.displayError("IOException on idImage.importData");
progressBar.dispose();
setCompleted(false);
return;
}
kernel = AlgorithmMorphology3D.SIZED_SPHERE;
sphereDiameter = 0.0f;
method = AlgorithmMorphology3D.ID_OBJECTS;
itersDilation = 0;
itersErosion = 0;
numPruningPixels = 0;
edgingType = 0;
idObjectsAlgo3D = new AlgorithmMorphology3D(idImage, kernel, sphereDiameter, method, itersDilation,
itersErosion, numPruningPixels, edgingType, wholeImage);
idObjectsAlgo3D.setProgressBarVisible(false);
idObjectsAlgo3D.run();
idObjectsAlgo3D.finalize();
idObjectsAlgo3D = null;
idImage.calcMinMax();
// ViewJFrameImage testFrame = new ViewJFrameImage(grayImage, null,
// new Dimension(600, 300), srcImage.getUserInterface());
numObjects = (int) idImage.getMax();
idArray = new int[totLength];
try {
idImage.exportData(0, totLength, idArray);
} catch (IOException e) {
MipavUtil.displayError("IOException on idImage.exportData");
progressBar.dispose();
setCompleted(false);
return;
}
idImage.disposeLocal();
idImage = null;
idCount = new int[numObjects + 1];
for (i = 0; i < totLength; i++) {
idCount[idArray[i]]++;
}
maxCount = 0;
maxID = -1;
for (i = 1; i <= numObjects; i++) {
if (idCount[i] > maxCount) {
maxCount = idCount[i];
maxID = i;
}
}
// Delete all but the largest object
for (i = 0; i < totLength; i++) {
if (idArray[i] != maxID) {
vol[i] = 0;
}
}
idCount = null;
idArray = null;
/*boolean test;
* test = true; if (test) { solidImage = new ModelImage(ModelStorageBase.BYTE, srcImage.getExtents(),
* "solidImage", srcImage.getUserInterface()); try { solidImage.importData(0, vol, true); }
* catch (IOException e) { MipavUtil.displayError("IOException on soldImage.importData");
* disposeProgressBar(); setCompleted(false); return; }
*
* new ViewJFrameImage(solidImage); progressBar.dispose(); setCompleted(true); return;} // if (test)*/
// Reset the INTERIOR voxels with at least one 6 neighbor EXTERIOR
// to be SURF voxels
flagVolume();
if (skPoints == null) {
try {
forceX = new double[totLength];
forceY = new double[totLength];
forceZ = new double[totLength];
} catch (OutOfMemoryError e) {
MipavUtil.displayError("Out of memory error when allocating force");
disposeProgressBar();
setCompleted(false);
return;
}
// Thicken the object with distCharges layers of extra voxels and
// compute the potential field
if (distCharges > 0) {
progressBar.setMessage("Padding the object");
Preferences.debug("Padding the object\n");
// First layer attaches itself to the SURF voxels
if (!expandVolume(SURF, PADDING_MIN)) {
MipavUtil.displayError("Error padding the object");
MipavUtil.displayError("Volume bounds are too tight");
disposeProgressBar();
setCompleted(false);
return;
}
// All other layers attach themselves to the previous one.
for (i = 1; i < distCharges; i++) {
if (!expandVolume((byte) (PADDING_MIN + (i - 1)), (byte) (PADDING_MIN + i))) {
MipavUtil.displayError("Error padding the object");
MipavUtil.displayError("Volume bounds are too tight");
disposeProgressBar();
setCompleted(false);
return;
}
}
} // if (distCharges > 0)
else if (distCharges < 0) {
progressBar.setMessage("Peeling the object");
Preferences.debug("Peeling the object\n");
for (i = 0; i > distCharges; i--) {
peelVolume();
}
} // else if (distCharges <0)
progressBar.setMessage("Calculating potential field");
Preferences.debug("Calculating potential field\n");
// Check volume padding - fast version
if (!quickCheckVolumePadding()) {
MipavUtil.displayError("Error - object touches bounding box");
disposeProgressBar();
setCompleted(false);
return;
}
if (!calculatePotentialField()) {
disposeProgressBar();
setCompleted(false);
return;
}
if (saveVF) {
progressBar.setMessage("Saving potential field");
Preferences.debug("Saving potential field\n");
gvfImage = new ModelImage(ModelImage.DOUBLE, srcImage.getExtents(), srcImage.getImageName() + "_xvf",
srcImage.getUserInterface());
try {
gvfImage.importData(0, forceX, true);
} catch (IOException error) {
if (gvfImage != null) {
gvfImage.disposeLocal();
gvfImage = null;
}
MipavUtil.displayError("Error on gvfImage.importData");
progressBar.dispose();
setCompleted(false);
return;
}
try {
gvfImage.saveImage(srcImage.getFileInfo(0).getFileDirectory(), srcImage.getImageName() + "_xvf",
FileBase.XML, true);
} catch (OutOfMemoryError error) {
if (gvfImage != null) {
gvfImage.disposeLocal();
gvfImage = null;
}
MipavUtil.displayError("Error on gvfImage.saveImage");
progressBar.dispose();
setCompleted(false);
return;
}
try {
gvfImage.importData(0, forceY, true);
} catch (IOException error) {
if (gvfImage != null) {
gvfImage.disposeLocal();
gvfImage = null;
}
MipavUtil.displayError("Error on gvfImage.importData");
progressBar.dispose();
setCompleted(false);
return;
}
try {
gvfImage.saveImage(srcImage.getFileInfo(0).getFileDirectory(), srcImage.getImageName() + "_yvf",
FileBase.XML, true);
} catch (OutOfMemoryError error) {
if (gvfImage != null) {
gvfImage.disposeLocal();
gvfImage = null;
}
MipavUtil.displayError("Error on gvfImage.saveImage");
progressBar.dispose();
setCompleted(false);
return;
}
try {
gvfImage.importData(0, forceZ, true);
} catch (IOException error) {
if (gvfImage != null) {
gvfImage.disposeLocal();
gvfImage = null;
}
MipavUtil.displayError("Error on gvfImage.importData");
progressBar.dispose();
setCompleted(false);
return;
}
try {
gvfImage.saveImage(srcImage.getFileInfo(0).getFileDirectory(), srcImage.getImageName() + "_zvf",
FileBase.XML, true);
} catch (OutOfMemoryError error) {
if (gvfImage != null) {
gvfImage.disposeLocal();
gvfImage = null;
}
MipavUtil.displayError("Error on gvfImage.saveImage");
progressBar.dispose();
setCompleted(false);
return;
}
gvfImage.disposeLocal();
gvfImage = null;
} // if (saveVF)
progressBar.setMessage("Detecting critical points\n");
progressBar.updateValue(92, activeImage);
Preferences.debug("Detecting critical points\n");
if (!getCriticalPoints()) {
progressBar.dispose();
setCompleted(false);
return;
}
// Generating the skeleton
progressBar.setMessage("Generating level 1 skeleton");
progressBar.updateValue(94, activeImage);
Preferences.debug("Generating level1 skeleton\n");
// Allocate skeleton structure
try {
skelSizePoints = 100000;
skelPoints = new double[skelSizePoints][3];
skelSizeSegments = 10000;
skelSegments = new int[skelSizeSegments][];
} catch (OutOfMemoryError e) {
MipavUtil.displayError("Error allocating skeleton structure");
progressBar.dispose();
setCompleted(false);
return;
}
if (!getLevel1Skeleton()) {
progressBar.dispose();
setCompleted(false);
return;
}
if (saveVF) {
progressBar.setMessage("Saving level 1 skeleton\n");
Preferences.debug("Saving level 1 skeleton\n");
file = new File(srcImage.getFileInfo(0).getFileDirectory() + srcImage.getImageName() + ".skf");
try {
raFile = new RandomAccessFile(file, "rw");
raFile.setLength(0);
raFile.writeInt(skelNumPoints);
for (i = 0; i < skelNumPoints; i++) {
for (j = 0; j < 3; j++) {
raFile.writeDouble(skelPoints[i][j]);
}
} // for (i = 0; i < skelNumPoints; i++)
raFile.writeInt(skelNumSegments);
for (i = 0; i < skelNumSegments; i++) {
for (j = 0; j < 4; j++) {
raFile.writeInt(skelSegments[i][j]);
}
} // for (i = 0; i < skelNumSegments; i++)
raFile.close();
} catch (IOException e) {
MipavUtil.displayError("IOEXception on new RandomAccessFile");
progressBar.dispose();
setCompleted(false);
return;
}
} // if (saveVF)
} // if (skPoints == null)
else { // skPoints != null
// Allocate skeleton structure
try {
skelSizePoints = 100000;
skelPoints = new double[skelSizePoints][3];
skelSizeSegments = 10000;
skelSegments = new int[skelSizeSegments][];
skelNumPoints = skPoints.length;
for (i = 0; i < skelNumPoints; i++) {
for (j = 0; j < 3; j++) {
skelPoints[i][j] = skPoints[i][j];
}
}
for (i = 0; i < skelNumPoints; i++) {
skPoints[i] = null;
}
skPoints = null;
skelNumSegments = skSegments.length;
for (i = 0; i < skelNumSegments; i++) {
skelSegments[i] = new int[4];
for (j = 0; j < 4; j++) {
skelSegments[i][j] = skSegments[i][j];
}
}
for (i = 0; i < skelNumSegments; i++) {
skSegments[i] = null;
}
skSegments = null;
} catch (OutOfMemoryError e) {
MipavUtil.displayError("Error allocating skeleton structure");
progressBar.dispose();
setCompleted(false);
return;
}
} // else skPoints != null
if (perHDPoints > 0.0f) {
progressBar.setMessage("Getting high divergence points");
progressBar.updateValue(96, activeImage);
Preferences.debug("Getting high divergence points\n");
// Get top perHDPoints fraction of highest negative divergence points
if (!getHighDivergencePoints()) {
progressBar.dispose();
setCompleted(false);
return;
}
Preferences.debug("Number of high divergence points = " + numHDPoints + "\n");
/*for (i = 0; i < numHDPoints; i++) {
* Preferences.debug(i + " = " + hdPoints[i][0] + " " + hdPoints[i][1] + " " +
* hdPoints[i][2] + "\n");}*/
progressBar.setMessage("Computing level 2 skeleton");
progressBar.updateValue(92, activeImage);
Preferences.debug("Computing level 2 skeleton\n");
if (!getLevel2Skeleton()) {
progressBar.dispose();
setCompleted(false);
return;
}
} // if (perHDPoints > 0.0f)
progressBar.updateValue(99, activeImage);
if (outputPoints) {
// Write out the skeleton points
// used is an array that specifies for each skeleton point whether or not
// it was already used. It is needed because intersection points belong
// to more than one segment and might be put in a VOI more than one time
try {
used = new boolean[skelNumPoints];
} catch (OutOfMemoryError e) {
MipavUtil.displayError("Out of memory error allocating used array");
progressBar.dispose();
setCompleted(false);
return;
}
// Output each segment
ptNum = 0;
for (i = 0; i < skelNumSegments; i++) {
// Output the left end point of the segment
segNum = 0;
haveSegColor = false;
if (!used[skelSegments[i][SKEL_SEG_LEFT]]) {
newPtVOI = new VOI(ptNum++, "point" + i + "_" + segNum + ".voi", zDim, VOI.POINT, -1);
segColor = newPtVOI.getColor();
haveSegColor = true;
xArr[0] = (float) skelPoints[skelSegments[i][SKEL_SEG_LEFT]][0];
yArr[0] = (float) skelPoints[skelSegments[i][SKEL_SEG_LEFT]][1];
zArr[0] = (float) skelPoints[skelSegments[i][SKEL_SEG_LEFT]][2];
newPtVOI.importCurve(xArr, yArr, zArr, (int) zArr[0]);
((VOIPoint) (newPtVOI.getCurves()[(int) zArr[0]].elementAt(0))).setFixed(true);
((VOIPoint) (newPtVOI.getCurves()[(int) zArr[0]].elementAt(0))).setLabel(String.valueOf(i));
srcImage.registerVOI(newPtVOI);
used[skelSegments[i][SKEL_SEG_LEFT]] = true;
segNum++;
} // if (!used[skelSegments[i][SKEL_SEG_LEFT]])
// Output the interior points
for (j = skelSegments[i][SKEL_SEG_FIRST]; j <= skelSegments[i][SKEL_SEG_LAST]; j++) {
if ((j != skelSegments[i][SKEL_SEG_LEFT]) && (j != skelSegments[i][SKEL_SEG_RIGHT])) {
if (!used[j]) {
newPtVOI = new VOI(ptNum++, "point" + i + "_" + segNum + ".voi", zDim, VOI.POINT, -1);
if (haveSegColor) {
newPtVOI.setColor(segColor);
} else {
segColor = newPtVOI.getColor();
haveSegColor = true;
}
xArr[0] = (float) skelPoints[j][0];
yArr[0] = (float) skelPoints[j][1];
zArr[0] = (float) skelPoints[j][2];
newPtVOI.importCurve(xArr, yArr, zArr, (int) zArr[0]);
((VOIPoint) (newPtVOI.getCurves()[(int) zArr[0]].elementAt(0))).setFixed(true);
((VOIPoint) (newPtVOI.getCurves()[(int) zArr[0]].elementAt(0))).setLabel(String.valueOf(i));
srcImage.registerVOI(newPtVOI);
used[j] = true;
segNum++;
}
}
} // for (j = skelSegments[i][SKEL_SEG_FIRST]; j <= skelSegments[i][SKEL_SEG_LAST]; j++)
// Output the right end point
if (!used[skelSegments[i][SKEL_SEG_RIGHT]]) {
newPtVOI = new VOI(ptNum++, "point" + i + "_" + segNum + ".voi", zDim, VOI.POINT, -1);
if (haveSegColor) {
newPtVOI.setColor(segColor);
} else {
segColor = newPtVOI.getColor();
haveSegColor = true;
}
xArr[0] = (float) skelPoints[skelSegments[i][SKEL_SEG_RIGHT]][0];
yArr[0] = (float) skelPoints[skelSegments[i][SKEL_SEG_RIGHT]][1];
zArr[0] = (float) skelPoints[skelSegments[i][SKEL_SEG_RIGHT]][2];
newPtVOI.importCurve(xArr, yArr, zArr, (int) zArr[0]);
((VOIPoint) (newPtVOI.getCurves()[(int) zArr[0]].elementAt(0))).setFixed(true);
((VOIPoint) (newPtVOI.getCurves()[(int) zArr[0]].elementAt(0))).setLabel(String.valueOf(i));
srcImage.registerVOI(newPtVOI);
used[skelSegments[i][SKEL_SEG_RIGHT]] = true;
segNum++;
} // if (!used[skelSegments[i][SKEL_SEG_RIGHT]])
} // for (i = 0; i < skelNumSegments; i++)
} // if (outputPoints)
else {
// Output only line segment end points
ptNum = 0;
for (i = 0; i < skelNumSegments; i++) {
newPtVOI = new VOI(ptNum++, "pointL" + i + ".voi", zDim, VOI.POINT, -1);
segColor = newPtVOI.getColor();
xArr[0] = (float) skelPoints[skelSegments[i][SKEL_SEG_LEFT]][0];
yArr[0] = (float) skelPoints[skelSegments[i][SKEL_SEG_LEFT]][1];
zArr[0] = (float) skelPoints[skelSegments[i][SKEL_SEG_LEFT]][2];
newPtVOI.importCurve(xArr, yArr, zArr, (int) zArr[0]);
((VOIPoint) (newPtVOI.getCurves()[(int) zArr[0]].elementAt(0))).setFixed(true);
((VOIPoint) (newPtVOI.getCurves()[(int) zArr[0]].elementAt(0))).setLabel(String.valueOf(i));
srcImage.registerVOI(newPtVOI);
newPtVOI = new VOI(ptNum++, "pointR" + i + ".voi", zDim, VOI.POINT, -1);
newPtVOI.setColor(segColor);
xArr[0] = (float) skelPoints[skelSegments[i][SKEL_SEG_RIGHT]][0];
yArr[0] = (float) skelPoints[skelSegments[i][SKEL_SEG_RIGHT]][1];
zArr[0] = (float) skelPoints[skelSegments[i][SKEL_SEG_RIGHT]][2];
newPtVOI.importCurve(xArr, yArr, zArr, (int) zArr[0]);
((VOIPoint) (newPtVOI.getCurves()[(int) zArr[0]].elementAt(0))).setFixed(true);
((VOIPoint) (newPtVOI.getCurves()[(int) zArr[0]].elementAt(0))).setLabel(String.valueOf(i));
srcImage.registerVOI(newPtVOI);
} // for (i = 0; i < skelNumSegments; i++)
} // else
Preferences.debug("Segments output = " + skelNumSegments + "\n");
Preferences.debug("Points output = " + ptNum + "\n");
srcImage.notifyImageDisplayListeners();
progressBar.dispose();
setCompleted(true);
return;
} // runAlgorithm
/**
* DOCUMENT ME!
*
* @param point DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private int addNewSkelSegment(int point) {
int retval = -1;
if (skelNumSegments >= skelSizeSegments) {
MipavUtil.displayError((skelNumSegments + 1) + " skeleton segments detected, but only " + skelSizeSegments +
" are allowed");
return -2;
}
try {
if (skelSegments[skelNumSegments] == null) {
skelSegments[skelNumSegments] = new int[4];
}
} catch (OutOfMemoryError e) {
MipavUtil.displayError("Error allocating memory for skelSegments");
return -2;
}
skelSegments[skelNumSegments][SKEL_SEG_LEFT] = point;
skelSegments[skelNumSegments][SKEL_SEG_RIGHT] = point;
skelSegments[skelNumSegments][SKEL_SEG_FIRST] = point;
skelSegments[skelNumSegments][SKEL_SEG_LAST] = point;
retval = skelNumSegments;
skelNumSegments++;
return retval;
} // addNewSkelSegment
/**
* DOCUMENT ME!
*
* @param pos DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private int addSkeletonPoint(double[] pos) {
int retval = skelNumPoints;
// Copy the point's position
skelPoints[retval][0] = pos[0];
skelPoints[retval][1] = pos[1];
skelPoints[retval][2] = pos[2];
// Increase the number of skeleton points
skelNumPoints++;
if (skelNumPoints >= skelSizePoints) {
MipavUtil.displayError("Too many skeleton points");
return -2;
}
return retval;
} // addSkeletonPoint
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean calculatePotentialField() {
short[][] bound;
short x, y, z;
int xm1, ym1, zm1;
boolean flagSurf, flagBound;
int idx;
int iidx;
int numBound = 0;
int zStartIndex, zEndIndex;
int s;
int yStartIndex, yEndIndex;
int startIndex, endIndex;
int v1, v2, v3;
double r, t;
int p;
int[] ng = new int[26];
try {
bound = new short[BOUND_SIZE][3];
} catch (OutOfMemoryError e) {
MipavUtil.displayError("Out of memory during bound allocation");
return false;
}
xm1 = xDim - 1;
ym1 = yDim - 1;
zm1 = zDim - 1;
// Save all the boundary voxels in the array bound
for (z = 1; z < zm1; z++) {
for (y = 1; y < ym1; y++) {
for (x = 1; x < xm1; x++) {
flagSurf = false;
flagBound = true;
idx = (z * sliceSize) + (y * xDim) + x;
// Case 1: treat the inner layer
if (vol[idx] == 0) {
continue;
}
// Consider six face neighbors, if anyone is zero, it is a boundary voxel
iidx = idx - 1;
if (vol[iidx] == 0) {
flagSurf = true;
}
if (!flagSurf || flagBound) {
iidx = idx + 1;
if (vol[iidx] == 0) {
flagSurf = true;
}
if (!flagSurf || flagBound) {
iidx = idx - xDim;
if (vol[iidx] == 0) {
flagSurf = true;
}
if (!flagSurf || flagBound) {
iidx = idx + xDim;
if (vol[iidx] == 0) {
flagSurf = true;
}
if (!flagSurf || flagBound) {
iidx = idx - sliceSize;
if (vol[iidx] == 0) {
flagSurf = true;
}
if (!flagSurf || flagBound) {
iidx = idx + sliceSize;
if (vol[iidx] == 0) {
flagSurf = true;
}
}
}
}
}
}
if (flagSurf) {
vol[idx] = SURF;
if (flagBound) {
// If no neighbor of this voxel is already marked as boundary, then
// mark this one. Or if we are taking all the boundary voxels
// (in this case flagBound stays true)
vol[idx] = BOUNDARY;
bound[numBound][0] = x;
bound[numBound][1] = y;
bound[numBound][2] = z;
numBound++;
if (numBound >= BOUND_SIZE) {
MipavUtil.displayError("Error: too many boundary points detected");
return false;
}
} // if (flagBound)
} // if (flagSurf)
} // for (x = 1; x < xm1; x++)
} // for (y = 1; y < ym1; y++)
} // for (z = 1; z < zm1; z++)
Preferences.debug("Found " + numBound + " boundary voxels\n");
// Sort the boundary array
sortBoundaryArray(numBound, bound);
// Compute the potential field
Preferences.debug("Computing potential field\n");
idx = -1;
for (z = 0; z < zDim; z++) {
Preferences.debug("Processing plane " + z + " out of " + (zDim - 1) + "\n");
progressBar.updateValue(z * 90 / (zDim - 1), activeImage);
// Find the boundary voxels that will influence this point
// Look at the z coordinate
zStartIndex = 0;
zEndIndex = numBound - 1;
for (s = 0; s < numBound; s++) {
if ((z - bound[s][2]) <= PF_THRESHOLD) {
zStartIndex = s;
break;
}
} // for (s = 0; s < numBound; s++)
for (s = numBound - 1; s >= zStartIndex; s--) {
if ((bound[s][2] - z) <= PF_THRESHOLD) {
zEndIndex = s;
break;
}
} // for (s = numBound-1; s>= zStartIndex; s--)
for (y = 0; y < yDim; y++) {
// Find the boundary voxels that will influence this point
// Look at the y coordinate
yStartIndex = zStartIndex;
yEndIndex = zEndIndex;
for (s = zStartIndex; s <= zEndIndex; s++) {
if ((y - bound[s][1]) <= PF_THRESHOLD) {
yStartIndex = s;
break;
}
} // for (s = zStartIndex; s <= zEndIndex; s++)
for (s = zEndIndex; s >= yStartIndex; s--) {
if ((bound[s][1] - y) <= PF_THRESHOLD) {
yEndIndex = s;
break;
}
} // for (s = zEndIndex; s >= yStartIndex; s--)
for (x = 0; x < xDim; x++) {
idx = idx + 1;
forceX[idx] = 0.0;
forceY[idx] = 0.0;
forceZ[idx] = 0.0;
if (vol[idx] == 0) {
// outside voxels have null force
continue;
} // if (vol[idx] == 0)
// Surface voxels (including those selected for the field calculation)
// are ignored for now. The force there will be the average of their
// neighbors. If we are to compute the force at the boundary voxels
// too, the force will point towards the exterior of the object
// (example: a 30x30x100 box)
if (vol[idx] == SURF) {
continue;
}
if (vol[idx] == BOUNDARY) {
continue;
}
// Find the boundary voxels that will influence this point
// Look at the x coordinate
startIndex = yStartIndex;
endIndex = yEndIndex;
for (s = yStartIndex; s <= yEndIndex; s++) {
if ((x - bound[s][0]) <= PF_THRESHOLD) {
startIndex = s;
break;
}
} // for (s = yStartIndex; s <= yEndIndex; s++)
for (s = yEndIndex; s >= startIndex; s--) {
if ((bound[s][0] - x) <= PF_THRESHOLD) {
endIndex = s;
break;
}
} // for (s = yEndIndex; s >= startIndex; s--)
if (endIndex < startIndex) {
// No boundary point is close enough to this point -
// take all the boundary points
startIndex = 0;
endIndex = numBound - 1;
} // if (endIndex < startIndex)
for (s = startIndex; s <= endIndex; s++) {
v1 = x - bound[s][0];
v2 = y - bound[s][1];
v3 = z - bound[s][2];
// euclidean metric
r = Math.sqrt((v1 * v1) + (v2 * v2) + (v3 * v3));
// r can be 0 if we are computing the force at boundary voxels too
// If the current point is a boundary point, some r will be zero,
// and that should be ignored
if (r != 0.0) {
// Raise r to the fieldStrength+1 power so that the force is
// 1/(dist^fieldStrength)
t = 1.00;
for (p = 0; p <= fieldStrength; p++) {
t = t * r;
}
r = t;
forceX[idx] = forceX[idx] + (v1 / r);
forceY[idx] = forceY[idx] + (v2 / r);
forceZ[idx] = forceZ[idx] + (v3 / r);
} // if (r != 0.0)
} // for (s = startIndex; s <= endIndex; s++)
} // for (x = 0; x < xDim; x++)
} // for (y = 0; y < yDim; y++)
} // for (z = 0; z < zDim; z++)
// delete the bound array - don't need it anywhere
for (s = 0; s < bound.length; s++) {
bound[s] = null;
}
bound = null;
// normalize force vectors
for (idx = 0; idx < totLength; idx++) {
// Only for interior voxels have forces been calculated
if (vol[idx] == EXTERIOR) {
continue;
}
r = (forceX[idx] * forceX[idx]) + (forceY[idx] * forceY[idx]) + (forceZ[idx] * forceZ[idx]);
if (r > 0.0) {
r = Math.sqrt(r);
forceX[idx] = forceX[idx] / r;
forceY[idx] = forceY[idx] / r;
forceZ[idx] = forceZ[idx] / r;
}
} // for (idx = 0; idx < totLength; idx++)
// Calculate the force at the surface
// voxels as the average of the interior neighbors
// face neighbors
ng[0] = +sliceSize;
ng[1] = -sliceSize;
ng[2] = +xDim;
ng[3] = -xDim;
ng[4] = +1;
ng[5] = -1;
// vertex neighbors
ng[6] = -sliceSize - xDim - 1;
ng[7] = -sliceSize - xDim + 1;
ng[8] = -sliceSize + xDim - 1;
ng[9] = -sliceSize + xDim + 1;
ng[10] = sliceSize - xDim - 1;
ng[11] = sliceSize - xDim + 1;
ng[12] = sliceSize + xDim - 1;
ng[13] = sliceSize + xDim + 1;
// edge neighbors
ng[14] = sliceSize + xDim;
ng[15] = sliceSize - xDim;
ng[16] = -sliceSize + xDim;
ng[17] = -sliceSize - xDim;
ng[18] = sliceSize + 1;
ng[19] = sliceSize - 1;
ng[20] = -sliceSize + 1;
ng[21] = -sliceSize - 1;
ng[22] = xDim + 1;
ng[23] = xDim - 1;
ng[24] = -xDim + 1;
ng[25] = -xDim - 1;
for (z = 1; z < zm1; z++) {
for (y = 1; y < ym1; y++) {
for (x = 1; x < xm1; x++) {
idx = (z * sliceSize) + (y * xDim) + x;
if ((vol[idx] == SURF) || (vol[idx] == BOUNDARY)) {
forceX[idx] = 0.0;
forceY[idx] = 0.0;
forceZ[idx] = 0.0;
// Look at the neighbors and average the forces if not 0
v1 = 0;
for (s = 0; s < 26; s++) {
iidx = idx + ng[s]; // index of neighbor
// Take only neighbors that are not SURF or BOUNDARY
// because those neighbors have force = 0
if ((vol[iidx] == SURF) || (vol[iidx] == BOUNDARY)) {
continue;
}
// Take only interior neighbors
if (vol[iidx] == EXTERIOR) {
continue;
}
forceX[idx] = forceX[idx] + forceX[iidx];
forceY[idx] = forceY[idx] + forceY[iidx];
forceZ[idx] = forceZ[idx] + forceZ[iidx];
v1++;
} // for (s = 0; s < 26; s++)
// average
if (v1 != 0) {
forceX[idx] = forceX[idx] / (double) v1;
forceY[idx] = forceY[idx] / (double) v1;
forceZ[idx] = forceZ[idx] / (double) v1;
} // if (v1 != 0)
// normalize
r = (forceX[idx] * forceX[idx]) + (forceY[idx] * forceY[idx]) + (forceZ[idx] * forceZ[idx]);
if (r > 0.0) {
r = Math.sqrt(r);
forceX[idx] = forceX[idx] / r;
forceY[idx] = forceY[idx] / r;
forceZ[idx] = forceZ[idx] / r;
} // if (r > 0.0)
} // if ((vol[idx] == SURF) || (vol[idx] == BOUNDARY))
} // for (x = 1; x < xm1; x++)
} // for (y = 1; y < ym1; y++)
} // for (z = 1; z < zm1; z++)
return true;
} // calculatePotentialField
/**
* DOCUMENT ME!
*
* @param forces DOCUMENT ME!
* @param numForces DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean changeInSign(double[][] forces, int numForces) {
// sign change notes: If one component is 0 in all vectors, it should be considered as a change in sign or else
// we might miss some critical points for which we have only NR_OF_SIGN_CHANGES - 1 changes in sign and the last
// component is 0 all over the cell. Example (2D): *->--<-* *->--<-* In the above example, the arrows
// indicate the new vectors at the 4 corners of a 2D cell. The x component changes sign, but the y component is
// 0 in all 4 corners, and thus we might miss this critical point if we require exactly 2 sign changes.
// Considering 0 everywhere as a change in sign will include this critical point.
// Change in sign for at least one of the vector components leads to a sort of
// medial surface.
//
// Change in sign for at least NR_OF_SIGN_CHANGES vector components
int s, i, s2;
int count;
boolean change;
if (numForces > 0) {
count = 0;
// check the components of these vectors.
// x
change = false;
if (forces[0][0] < -EPSILON) {
s = -1;
} else if (forces[0][0] > EPSILON) {
s = 1;
} else {
s = 0;
}
for (i = 1; i < numForces; i++) {
if (forces[i][0] < -EPSILON) {
s2 = -1;
} else if (forces[i][0] > EPSILON) {
s2 = 1;
} else {
s2 = 0;
}
if (s2 != s) {
count++;
change = true;
break;
}
} // for (i = 1; i < numForces; i++)
if ((!change) && (s == 0)) {
// no change in sign but sign is 0
count++;
}
if (count >= NR_OF_SIGN_CHANGES) {
// return if at least NR_OF_SIGN_CHANGES vector components change sign
return true;
}
// y
change = false;
if (forces[0][1] < -EPSILON) {
s = -1;
} else if (forces[0][1] > EPSILON) {
s = 1;
} else {
s = 0;
}
for (i = 1; i < numForces; i++) {
if (forces[i][1] < -EPSILON) {
s2 = -1;
} else if (forces[i][1] > EPSILON) {
s2 = 1;
} else {
s2 = 0;
}
if (s2 != s) {
count++;
change = true;
break;
}
} // for (i = 1; i < numForces; i++)
if ((!change) && (s == 0)) {
// no change in sign but sign is 0
count++;
}
if (count >= NR_OF_SIGN_CHANGES) {
// return if at least NR_OF_SIGN_CHANGES vector components change sign
return true;
}
// z
change = false;
if (forces[0][2] < -EPSILON) {
s = -1;
} else if (forces[0][2] > EPSILON) {
s = 1;
} else {
s = 0;
}
for (i = 1; i < numForces; i++) {
if (forces[i][2] < -EPSILON) {
s2 = -1;
} else if (forces[i][2] > EPSILON) {
s2 = 1;
} else {
s2 = 0;
}
if (s2 != s) {
count++;
change = true;
break;
}
} // for (i = 1; i < numForces; i++)
if ((!change) && (s == 0)) {
// no change in sign but sign is 0
count++;
}
if (count >= NR_OF_SIGN_CHANGES) {
// return if at least NR_OF_SIGN_CHANGES vector components change sign
return true;
}
} // if (numForces > 0)
return false;
} // changeInSign(double forces[][], int numForces)
/**
* DOCUMENT ME!
*
* @param indices DOCUMENT ME!
* @param numIndices DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean changeInSign(int[] indices, int numIndices) {
// See notes in the other changeInSign routine
int s, i, s2;
int count;
boolean change;
// change in sign for at least NR_OF_SIGN_CHANGES vector components
if (numIndices > 0) {
count = 0;
// check the components of these vectors
// x
change = false;
if (forceX[indices[0]] < -EPSILON) {
s = -1;
} else if (forceX[indices[0]] > EPSILON) {
s = 1;
} else {
s = 0;
}
for (i = 1; i < numIndices; i++) {
if (forceX[indices[i]] < -EPSILON) {
s2 = -1;
} else if (forceX[indices[i]] > EPSILON) {
s2 = 1;
} else {
s2 = 0;
}
if (s2 != s) {
count++;
change = true;
break;
}
} // for (i = 1; i < numIndices; i++)
if ((!change) && (s == 0)) {
// no change in sign but sign is 0
count++;
}
if (count >= NR_OF_SIGN_CHANGES) {
// return if at least NR_OF_SIGN_CHANGES vector components change sign
return true;
}
// Y
change = false;
if (forceY[indices[0]] < -EPSILON) {
s = -1;
} else if (forceY[indices[0]] > EPSILON) {
s = 1;
} else {
s = 0;
}
for (i = 1; i < numIndices; i++) {
if (forceY[indices[i]] < -EPSILON) {
s2 = -1;
} else if (forceY[indices[i]] > EPSILON) {
s2 = 1;
} else {
s2 = 0;
}
if (s2 != s) {
count++;
change = true;
break;
}
} // for (i = 1; i < numIndices; i++)
if ((!change) && (s == 0)) {
// no change in sign but sign is 0
count++;
}
if (count >= NR_OF_SIGN_CHANGES) {
// return if at least NR_OF_SIGN_CHANGES vector components change sign
return true;
}
// Z
change = false;
if (forceZ[indices[0]] < -EPSILON) {
s = -1;
} else if (forceZ[indices[0]] > EPSILON) {
s = 1;
} else {
s = 0;
}
for (i = 1; i < numIndices; i++) {
if (forceZ[indices[i]] < -EPSILON) {
s2 = -1;
} else if (forceZ[indices[i]] > EPSILON) {
s2 = 1;
} else {
s2 = 0;
}
if (s2 != s) {
count++;
change = true;
break;
}
} // for (i = 1; i < numIndices; i++)
if ((!change) && (s == 0)) {
// no change in sign but sign is 0
count++;
}
if (count >= NR_OF_SIGN_CHANGES) {
// return if at least NR_OF_SIGN_CHANGES vector components change sign
return true;
}
} // if (numIndices > 0)
return false;
} // changeInSign(int indices[], int numIndices)
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean checkVolumePadding() {
// Make sure the volume is padded by enough empty planes in all 3 directions
// so that placing charges at the specified distance from the boundary will
// still leave a plane of empty voxels in each direction
int x, y, z;
int minX = Integer.MAX_VALUE;
int maxX = Integer.MIN_VALUE;
int minY = Integer.MAX_VALUE;
int maxY = Integer.MIN_VALUE;
int minZ = Integer.MAX_VALUE;
int maxZ = Integer.MIN_VALUE;
int idx;
for (z = 0; z < zDim; z++) {
for (y = 0; y < yDim; y++) {
for (x = 0; x < xDim; x++) {
idx = (z * sliceSize) + (y * xDim) + x;
if (volFloat[idx] >= minObjectValue) {
if (x < minX) {
minX = x;
}
if (y < minY) {
minY = y;
}
if (z < minZ) {
minZ = z;
}
if (x > maxX) {
maxX = x;
}
if (y > maxY) {
maxY = y;
}
if (z > maxZ) {
maxZ = z;
}
}
}
}
}
Preferences.debug("checkVolumePadding\n");
Preferences.debug("minX = " + minX + " minY = " + minY + " minZ = " + minZ + "\n");
Preferences.debug("maxX = " + maxX + " maxY = " + maxY + " maxZ = " + maxZ + "\n");
if (((minX - distCharges) <= 0) || ((minY - distCharges) <= 0) || ((minZ - distCharges) <= 0) ||
((maxX + distCharges) >= (xDim - 1)) || ((maxY + distCharges) >= (yDim - 1)) ||
((maxZ + distCharges) >= (zDim - 1))) {
return false;
}
return true;
} // checkVolumePadding
/**
* DOCUMENT ME!
*
* @param pos DOCUMENT ME!
* @param originCP DOCUMENT ME!
* @param maxDistance DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private int closeToCP(double[] pos, int originCP, double maxDistance) {
int i;
double a, b;
// see if it's close to a critical point except the one specified in originCP
for (i = 0; i < numCritPoints; i++) {
// Ignore the critical point that started this streamline
if (i == originCP) {
continue;
}
if (Math.abs(critPts[i][0] - pos[0]) < maxDistance) {
a = Math.abs(critPts[i][0] - pos[0]);
if ((a + Math.abs(critPts[i][1] - pos[1])) < maxDistance) {
b = Math.abs(critPts[i][1] - pos[1]);
if ((a + b + Math.abs(critPts[i][2] - pos[2])) < maxDistance) {
// the point is "close" to a critical point
return i;
}
}
}
}
return -1;
} // closeToCP
/**
* DOCUMENT ME!
*
* @param pos DOCUMENT ME!
* @param originSkel DOCUMENT ME!
* @param nrAlreadyInSkel DOCUMENT ME!
* @param maxDistance DOCUMENT ME!
* @param crtSegmentLength DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private int closeToSkel(double[] pos, int originSkel, int nrAlreadyInSkel, double maxDistance,
int crtSegmentLength) {
int i;
double a, b;
boolean[] endPoint = new boolean[1];
int seg;
int dToLeft, dToRight;
// See if it's close to a skeleton point, ignoring the one point specified
// by originSkel
for (i = 0; i < nrAlreadyInSkel; i++) {
// ignore the point specified by originSkel
if (i == originSkel) {
continue;
} // if (i == originSkel)
// incrmental testing of the "close to" condition for higher speed
if (Math.abs(skelPoints[i][0] - pos[0]) < maxDistance) {
a = Math.abs(skelPoints[i][0] - pos[0]);
if ((a + Math.abs(skelPoints[i][1] - pos[1])) < maxDistance) {
b = Math.abs(skelPoints[i][1] - pos[1]);
if ((a + b + Math.abs(skelPoints[i][2] - pos[2])) < maxDistance) {
// The point is "close" to a skeleton point
// If the skeleton point we are close to is also close to one of
// the segment end points, (but it's not an end point)
// do not report as being close to the point, wait to get to one
// of the segment end points
endPoint[0] = false;
seg = getSkelSegment(i, endPoint);
if (seg == -2) {
return -2;
}
if (endPoint[0]) {
// report the intersection if we are at an end point
return i;
} else {
// see how close we are to the endpoints of seg
dToLeft = i - skelSegments[seg][SKEL_SEG_FIRST];
dToRight = skelSegments[seg][SKEL_SEG_LAST] - i;
if ((dToLeft > SP_CLOSE_TO_SEGMENT_ENDPOINT) && (dToRight > SP_CLOSE_TO_SEGMENT_ENDPOINT)) {
// If we are close to an end point, report the intersection
return i;
}
// Otherwise, we are close to a segment given by seg, but we
// are also just a few points from the seg's end point and we
// hope to end the current segment at the same point where seg
// ends. However, if the current segment's length is comparable
// to SP_CLOSE_TO_SEGMENT_ENDPOINT, then we should stop right
// here because this won't look good
// Comparable means not more than twice as long as
// SP_CLOSE_TO_SEGMENT_ENDPOINT
if (crtSegmentLength <= (2 * SP_CLOSE_TO_SEGMENT_ENDPOINT)) {
return i;
}
}
}
}
}
} // for (i = 0; i < nrAlreeadyInSkel; i++)
return -1;
} // closeToSkel
/**
* Constructs a string of the contruction parameters and outputs the string to the messsage frame if the logging
* procedure is turned on.
*/
private void constructLog() {
historyString = new String("Skeletonization3D(" + minObjectValue + ", " + sliceHoleFilling + ", " + saveVF +
", " + distCharges + ", " + fieldStrength + ", " + perHDPoints + ", " +
outputPoints + "\n");
}
/**
* DOCUMENT ME!
*/
private void createCylinder() {
byte[] vol = new byte[250 * 250 * 250];
int x, y, z;
int sliceSize = 250 * 250;
int[] extents = new int[3];
extents[0] = 250;
extents[1] = 250;
extents[2] = 250;
ModelImage cylImage;
// Must leave first and last slices blank
for (z = 1; z < 249; z++) {
for (y = 0; y < 250; y++) {
for (x = 0; x < 250; x++) {
if ((((x - 125) * (x - 125)) + ((y - 125) * (y - 125))) <= (50 * 50)) {
vol[(z * sliceSize) + (y * 250) + x] = 1;
}
}
}
}
cylImage = new ModelImage(ModelImage.BYTE, extents, "cylinder", srcImage.getUserInterface());
try {
cylImage.importData(0, vol, true);
} catch (IOException error) {
if (cylImage != null) {
cylImage.disposeLocal();
cylImage = null;
}
MipavUtil.displayError("Error on cylImage.importData");
progressBar.dispose();
setCompleted(false);
return;
}
try {
cylImage.saveImage(srcImage.getFileInfo(0).getFileDirectory(), "cylinder", FileBase.XML, true);
} catch (OutOfMemoryError error) {
if (cylImage != null) {
cylImage.disposeLocal();
cylImage = null;
}
MipavUtil.displayError("Error on cylImage.saveImage");
progressBar.dispose();
setCompleted(false);
return;
}
return;
} // createCylinder
/**
* DOCUMENT ME!
*/
private void deleteLastSkelSegment() {
if (skelNumSegments > 0) {
skelNumSegments--;
}
return;
} // deleteLastSkelSegment
/**
* DOCUMENT ME!
*
* @param pos1 DOCUMENT ME!
* @param pos2 DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private double distance(double[] pos1, double[] pos2) {
return (Math.abs(pos1[0] - pos2[0]) + Math.abs(pos1[1] - pos2[1]) + Math.abs(pos1[2] - pos2[2]));
} // distance
/**
* DOCUMENT ME!
*
* @param padTarget DOCUMENT ME!
* @param padCharacter DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean expandVolume(byte padTarget, byte padCharacter) {
int x, y, z;
int idx;
int ii;
int iidx;
// face neighbors
int[] ng = new int[] { +sliceSize, -sliceSize, +xDim, -xDim, +1, -1 };
// Look at face neighbors only because that gives the best result,
// compared with looking at face and edge or
// face, edge, and vertex
for (z = 0; z < zDim; z++) {
for (y = 0; y < yDim; y++) {
for (x = 0; x < xDim; x++) {
idx = (z * sliceSize) + (y * xDim) + x;
if (vol[idx] == padTarget) {
// Look at all the face neighbors of this voxel
// and replace all the "blank" neighbors with the new value
for (ii = 0; ii < 6; ii++) {
iidx = idx + ng[ii];
if ((iidx < 0) || (iidx >= totLength)) {
return false;
}
if (vol[iidx] == EXTERIOR) {
vol[iidx] = padCharacter;
}
}
}
}
}
}
return true;
} // expandVolume
/**
* DOCUMENT ME!
*
* @param x DOCUMENT ME!
* @param y DOCUMENT ME!
* @param z DOCUMENT ME!
* @param cellSize DOCUMENT ME!
* @param critPt DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean findCriticalPointInFloatCell(double x, double y, double z, double cellSize, double[] critPt) {
int xx, yy, zz;
double[][] cv = new double[8][3];
// interpolate vector values at each of the 8 vertices of the cell
cv[0] = interpolation(x, y, z);
cv[1] = interpolation(x + cellSize, y, z);
cv[2] = interpolation(x, y + cellSize, z);
cv[3] = interpolation(x + cellSize, y + cellSize, z);
cv[4] = interpolation(x, y, z + cellSize);
cv[5] = interpolation(x + cellSize, y, z + cellSize);
cv[6] = interpolation(x, y + cellSize, z + cellSize);
cv[7] = interpolation(x + cellSize, y + cellSize, z + cellSize);
// If first vertex vector (corresponding to (x, y, z)) is (0, 0, 0),
// then return (x, y, z) as the critical point
if ((cv[0][0] < EPSILON) && (cv[0][0] > -EPSILON) && (cv[0][1] < EPSILON) && (cv[0][1] > -EPSILON) &&
(cv[0][2] < EPSILON) && (cv[0][2] > -EPSILON)) {
critPt[0] = x;
critPt[1] = y;
critPt[2] = z;
return true;
}
// The cell is a candidate cell if there is a change of sign
// in one of the vector components among all eight vertices of the cell
if (changeInSign(cv, 8)) {
// If cell size < 1/CELL_SUBDIVISION_FACTOR,
// stop here and assume critical point is in the center of the cell
if (cellSize <= (1.0 / CELL_SUBDIVISION_FACTOR)) {
critPt[0] = x + (cellSize / 2.0);
critPt[1] = y + (cellSize / 2.0);
critPt[2] = z + (cellSize / 2.0);
return true;
} // if (cellSize <= (1.0/CELL_SUBDIVISION_FACTOR))
// It is a candidate cell and it's not small enough
// Divide the cell in 8 subcells
// and try to find the critical point in one of the subcells
for (zz = 0; zz < 2; zz++) {
for (yy = 0; yy < 2; yy++) {
for (xx = 0; xx < 2; xx++) {
if (findCriticalPointInFloatCell(x + (xx * cellSize / 2.0), y + (yy * cellSize / 2.0),
z + (zz * cellSize / 2.0), cellSize / 2.0, critPt)) {
// critPt is already set
return true;
}
}
}
}
} // if (changeInSign(cv, 8))
return false;
} // findCriticalPointInFloatCell
/**
* DOCUMENT ME!
*
* @param x DOCUMENT ME!
* @param y DOCUMENT ME!
* @param z DOCUMENT ME!
* @param inds DOCUMENT ME!
* @param critPt DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean findCriticalPointInIntCell(int x, int y, int z, int[] inds, double[] critPt) {
int xx, yy, zz;
// If first vertex vector (corresponding to (x, y, z) with index in inds[0])
// is (0, 0, 0), then return (x, y, z) as the critical point
if ((forceX[inds[0]] < EPSILON) && (forceX[inds[0]] > -EPSILON) && (forceY[inds[0]] < EPSILON) &&
(forceY[inds[0]] > -EPSILON) && (forceZ[inds[0]] < EPSILON) && (forceZ[inds[0]] > -EPSILON)) {
critPt[0] = x;
critPt[1] = y;
critPt[2] = z;
return true;
}
// The cell is a candidate cell if there is a change of sign
// in one of the vector components among all the eight vertices of the cell
if (changeInSign(inds, 8)) {
// It is a candidate cell.
// Divide the cell in 8 subcells
// For each of those 8 subcells do the candidate test again
// and try to find the critical point in one of the candidate subcells
for (zz = 0; zz < 2; zz++) {
for (yy = 0; yy < 2; yy++) {
for (xx = 0; xx < 2; xx++) {
if (findCriticalPointInFloatCell(x + (xx / 2.0), y + (yy / 2.0), z + (zz / 2.0), 0.50,
critPt)) {
// critPt is already set
return true;
}
}
}
}
} // if (changeInSign(inds, 8))
return false;
} // findCriticalPointInIntCell
/**
* DOCUMENT ME!
*/
private void flagVolume() {
int i, s;
int x, y, z, idx, idx2;
// Only face neighbors
int[] neighborhood = new int[] { -1, +1, -xDim, +xDim, -sliceSize, +sliceSize };
for (i = 0; i < totLength; i++) {
// EXTERIOR == 0
if (vol[i] != 0) {
vol[i] = INTERIOR;
}
} // for (i = 0; i < totLength; i++)
// Look at the interior voxels.
// If an INTERIOR voxel has an EXTERIOR neighbor,
// then it is a SURFace voxel.
// Look only at the neighbors defined by the neighborhood
for (z = 1; z < (zDim - 1); z++) {
for (y = 1; y < (yDim - 1); y++) {
for (x = 1; x < (xDim - 1); x++) {
idx = (z * sliceSize) + (y * xDim) + x;
if (vol[idx] == INTERIOR) {
for (s = 0; s < 6; s++) {
idx2 = idx + neighborhood[s];
if (vol[idx2] == EXTERIOR) {
vol[idx] = SURF;
break;
}
}
}
}
}
}
return;
} // flagVolume
/**
* DOCUMENT ME!
*
* @param xPlane DOCUMENT ME!
*/
private void floodFillXPlane(int xPlane) {
// Floodfill each x plane with OUTSIDE_3 values
int idx, idxS, idxN;
boolean anyChange = true;
int y, z;
// Set (y = 0, z = 0) point to OUTSIDE_3
idx = xPlane;
vol[idx] = OUTSIDE_3;
while (anyChange) {
anyChange = false;
// Loop from left to right and top to bottom
for (y = 0; y < yDim; y++) {
for (z = 0; z < zDim; z++) {
idxS = (z * sliceSize) + (y * xDim) + idx;
// If the point is set to OUTSIDE_3, then set all empty neighbors
// to OUTSIDE_3
if (vol[idxS] == OUTSIDE_3) {
idxN = idxS + sliceSize;
if ((z < (zDim - 1)) &&
((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1) || (vol[idxN] == OUTSIDE_2))) {
vol[idxN] = OUTSIDE_3;
anyChange = true;
}
idxN = idxS - sliceSize;
if ((z > 0) && ((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1) || (vol[idxN] == OUTSIDE_2))) {
vol[idxN] = OUTSIDE_3;
anyChange = true;
}
idxN = idxS + xDim;
if ((y < (yDim - 1)) &&
((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1) || (vol[idxN] == OUTSIDE_2))) {
vol[idxN] = OUTSIDE_3;
anyChange = true;
}
idxN = idxS - xDim;
if ((y > 0) && ((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1) || (vol[idxN] == OUTSIDE_2))) {
vol[idxN] = OUTSIDE_3;
anyChange = true;
}
} // if (vol[idxS] == OUTSIDE_3)
} // for (z = 0; z < zDim; z++)
} // for (y = 0; y < yDim; y++)
if (anyChange) {
// Same loop but bottom to top and right to left
anyChange = false;
for (y = yDim - 1; y >= 0; y--) {
for (z = zDim - 1; z >= 0; z--) {
idxS = (z * sliceSize) + (y * xDim) + idx;
// If the point is set to OUTSIDE_3, then set all empty neighbors
// to OUTSIDE_3
if (vol[idxS] == OUTSIDE_3) {
idxN = idxS + sliceSize;
if ((z < (zDim - 1)) &&
((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1) || (vol[idxN] == OUTSIDE_2))) {
vol[idxN] = OUTSIDE_3;
anyChange = true;
}
idxN = idxS - sliceSize;
if ((z > 0) && ((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1) || (vol[idxN] == OUTSIDE_2))) {
vol[idxN] = OUTSIDE_3;
anyChange = true;
}
idxN = idxS + xDim;
if ((y < (yDim - 1)) &&
((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1) || (vol[idxN] == OUTSIDE_2))) {
vol[idxN] = OUTSIDE_3;
anyChange = true;
}
idxN = idxS - xDim;
if ((y > 0) && ((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1) || (vol[idxN] == OUTSIDE_2))) {
vol[idxN] = OUTSIDE_3;
anyChange = true;
}
} // if (vol[idxS] == OUTSIDE_3)
} // for (z = zDim - 1; z >= 0; z--)
} // for (y = yDim - 1; y >= 0; y--)
} // if (anyChange)
} // while (anyChange)
return;
} // floodFillXPlane
/**
* DOCUMENT ME!
*
* @param yPlane DOCUMENT ME!
*/
private void floodFillYPlane(int yPlane) {
// Floodfill each y plane with OUTSIDE_2 values
int idx, idxS, idxN;
boolean anyChange = true;
int x, z;
// Set point with (x = 0, z = 0) to OUTSIDE_2
idx = yPlane * xDim;
vol[idx] = OUTSIDE_2;
while (anyChange) {
anyChange = false;
// Loop from left to right and from top to bottom
for (x = 0; x < xDim; x++) {
for (z = 0; z < zDim; z++) {
idxS = (z * sliceSize) + idx + x;
// If the point is set to OUTSIDE_2, then set all empty neighbors
// to OUTSIDE_2
if (vol[idxS] == OUTSIDE_2) {
idxN = idxS + sliceSize;
if ((z < (zDim - 1)) && ((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1))) {
vol[idxN] = OUTSIDE_2;
anyChange = true;
}
idxN = idxS - sliceSize;
if ((z > 0) && ((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1))) {
vol[idxN] = OUTSIDE_2;
anyChange = true;
}
idxN = idxS + 1;
if ((x < (xDim - 1)) && ((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1))) {
vol[idxN] = OUTSIDE_2;
anyChange = true;
}
idxN = idxS - 1;
if ((x > 0) && ((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1))) {
vol[idxN] = OUTSIDE_2;
anyChange = true;
}
} // if (vol[idxS == OUTSIDE_2)
} // for (z = 0; z < zDim; z++)
} // for (x = 0; x < xDim; x++)
} // while (anyChange)
if (anyChange) {
// Same loop but bottom to top and right to left
anyChange = false;
for (x = xDim - 1; x >= 0; x--) {
for (z = zDim - 1; z >= 0; z--) {
idxS = (z * sliceSize) + idx + x;
// If the point is set to OUTSIDE_2, then set all empty neighbors
// to OUTSIDE_2
if (vol[idxS] == OUTSIDE_2) {
idxN = idxS + sliceSize;
if ((z < (zDim - 1)) && ((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1))) {
vol[idxN] = OUTSIDE_2;
anyChange = true;
}
idxN = idxS - sliceSize;
if ((z > 0) && ((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1))) {
vol[idxN] = OUTSIDE_2;
anyChange = true;
}
idxN = idxS + 1;
if ((x < (xDim - 1)) && ((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1))) {
vol[idxN] = OUTSIDE_2;
anyChange = true;
}
idxN = idxS - 1;
if ((x > 0) && ((vol[idxN] == 0) || (vol[idxN] == OUTSIDE_1))) {
vol[idxN] = OUTSIDE_2;
anyChange = true;
}
} // if (vol[idxS] == OUTSIDE_2)
} // for (z = zDim - 1; z >= 0; z--)
} // for (x = xDim - 1; x >= 0; x--)
} // if (anyChange)
return;
} // floodFillYPlane
/**
* DOCUMENT ME!
*
* @param zPlane DOCUMENT ME!
*/
private void floodFillZPlane(int zPlane) {
int idx, idxS, idxN;
boolean anyChange = true;
int x, y;
// Floodfill each z plane with OUTSIDE_1 values
// Set (x = 0, y = 0) point to OUTSIDE_1
idx = zPlane * sliceSize;
vol[idx] = OUTSIDE_1;
while (anyChange) {
anyChange = false;
// loop from left to right and top to bottom
for (x = 0; x < xDim; x++) {
for (y = 0; y < yDim; y++) {
idxS = idx + (y * xDim) + x;
// If the point is set to OUTSIDE_1, then set all empty neighbors
// to OUTSIDE_1
if (vol[idxS] == OUTSIDE_1) {
idxN = idxS + xDim;
if ((y < (yDim - 1)) && (vol[idxN] == 0)) {
vol[idxN] = OUTSIDE_1;
anyChange = true;
}
idxN = idxS - xDim;
if ((y > 0) && (vol[idxN] == 0)) {
vol[idxN] = OUTSIDE_1;
anyChange = true;
}
idxN = idxS + 1;
if ((x < (xDim - 1)) && (vol[idxN] == 0)) {
vol[idxN] = OUTSIDE_1;
anyChange = true;
}
idxN = idxS - 1;
if ((x > 1) && (vol[idxN] == 0)) {
vol[idxN] = OUTSIDE_1;
anyChange = true;
}
} // if (vol[idxS] == OUTSIDE_1)
} // for (y = 0; y < yDim; y++)
} // for (x = 0; x < xDim; x++)
if (anyChange) {
// Same loop but bottom to top and right to left
anyChange = false;
for (x = xDim - 1; x >= 0; x--) {
for (y = yDim - 1; y >= 0; y--) {
idxS = idx + (y * xDim) + x;
// If the point is set to OUTSIDE_1, then set all empty neighbors
// to OUTSIDE_1
if (vol[idxS] == OUTSIDE_1) {
idxN = idxS + xDim;
if ((y < (yDim - 1)) && (vol[idxN] == 0)) {
vol[idxN] = OUTSIDE_1;
anyChange = true;
}
idxN = idxS - xDim;
if ((y > 0) && (vol[idxN] == 0)) {
vol[idxN] = OUTSIDE_1;
anyChange = true;
}
idxN = idxS + 1;
if ((x < (xDim - 1)) && (vol[idxN] == 0)) {
vol[idxN] = OUTSIDE_1;
anyChange = true;
}
idxN = idxS - 1;
if ((x > 0) && (vol[idxN] == 0)) {
vol[idxN] = OUTSIDE_1;
anyChange = true;
}
} // if (vol[idxS] == OUTSIDE_1)
} // for (y = yDim - 1; y >= 0; y--)
} // for (x = xDim - 1; x >= 0; x--)
} // if (anyChange)
} // while (anyChange)
return;
} // floodFillZPlane
/**
* DOCUMENT ME!
*
* @param originCP DOCUMENT ME!
* @param lookInCP DOCUMENT ME!
* @param startPt DOCUMENT ME!
* @param whereTo DOCUMENT ME!
* @param critPtInSkeleton DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean followStreamLines(int originCP, boolean lookInCP, double[] startPt, double[] whereTo,
int[] critPtInSkeleton) {
// Creates an entire skeleton segment
int i;
double[] startPos = new double[3];
double[] nextPos = new double[3];
double[] lastAddedSkelPoint = new double[3];
int nrAlreadyInSkel;
int step;
boolean stop;
int crtSegment, newSeg, segToBeSplit;
boolean[] endPoint = new boolean[1];
int sp, cp, s, ocpSkelPos;
int crtSegLength = 0;
int saveCrtSegLen;
int quot;
int rem;
int exit_status = FSL_EXS_ERROR;
int exit_data = -1;
boolean first_iteration = true;
// Used to limit the search in the skeleton only to points not in the current segment
nrAlreadyInSkel = skelNumPoints;
startPos[0] = startPt[0];
startPos[1] = startPt[1];
startPos[2] = startPt[2];
// The position of the original critical point in the skeleton array if it was already
// there at the start of this function
ocpSkelPos = -1;
// Add the start point to the skeleton if not already there
// The point can already be in the skeleton if it's a critical point
// that was added as part of a previous segment (example: a saddle point
// belongs to at least 2 segments)
// The critPtInSkeleton array tells us if a critical point is already in the
// skeleton or not and if it is, it tells us its location
s = -1;
if (originCP != -1) {
s = critPtInSkeleton[originCP];
ocpSkelPos = s;
if (s == -1) {
s = addSkeletonPoint(startPos);
if (s == -2) {
return false;
}
// Update the critPtInSkeleton array
critPtInSkeleton[originCP] = s;
}
} // if (originCP != -1)
else {
s = addSkeletonPoint(startPos);
if (s == -2) {
return false;
}
}
lastAddedSkelPoint[0] = startPos[0];
lastAddedSkelPoint[1] = startPos[1];
lastAddedSkelPoint[2] = startPos[2];
// Add a new segment to the skeleton starting and ending at this point
crtSegment = addNewSkelSegment(s);
if (s == -2) {
return false;
}
// There is a new skeleton segment added after this point
// Make sure you set it correctly or delete it before leaving this function
exit_status = FSL_EXS_ERROR;
exit_data = 0;
first_iteration = true;
step = 0;
stop = false;
saveCrtSegLen = crtSegLength;
while (!stop) {
// If startPos is on the bounding box or outside, remove this segment
if ((startPos[0] <= 0) || (startPos[0] >= (xDim - 1)) || (startPos[1] <= 0) ||
(startPos[1] >= (yDim - 1)) || (startPos[2] <= 0) || (startPos[2] >= (zDim - 1))) {
exit_status = FSL_EXS_OUTSIDE;
stop = true;
break;
}
step++;
// At every multiple of PROGRESS_CHECK_INTERVAL steps,
// take a moment to see if we are moving at all
quot = step / PROGRESS_CHECK_INTERVAL;
rem = step % PROGRESS_CHECK_INTERVAL;
if (rem == 0) {
if (crtSegLength > saveCrtSegLen) {
// yes we are moving - continue
saveCrtSegLen = crtSegLength;
// but not forever
// MAX_NUM_STEP_INTERVALS times PROGRESS_STEP_INTERVAL steps
// should be enough
if (quot > MAX_NUM_STEP_INTERVALS) {
// Stop if more than ... steps were performed. Most likely we are
// chasing our own tail.
exit_status = FSL_EXS_TOO_MANY_STEPS;
stop = true;
break;
} // if (quot > MAX_NUM_STEP_INTERVALS)
} // if (crtSegLength > saveCrtSegLen)
else {
// we didn't add any skeleton point in the last PROGRESS_CHECK_INTERVAL
// steps. We should stop
exit_status = FSL_EXS_TOO_MANY_STEPS;
stop = true;
break;
}
} // if (rem == 0)
// Compute current segment length so far
crtSegLength = skelSegments[crtSegment][SKEL_SEG_LAST] - skelSegments[crtSegment][SKEL_SEG_FIRST] + 1;
// If this point is close to another point that is already part of the skeleton
// but not in the same segment, we should stop. The points in the same segment
// are excluded from the search since we are only searching among the points that
// existed in the Skel array when this function started.
// If we are starting from a critical point and we are at the first iteration,
// don't check if we are close to a skeleton point. We may be close to a
// skeleton point now, but we may be moving away from it at the next step.
if ((originCP != -1) && (first_iteration)) {
// don't check
} // if ((originCP != -1) && (first_iteration))
else {
sp = closeToSkel(startPos, ocpSkelPos, nrAlreadyInSkel, SP_SMALL_DISTANCE, crtSegLength);
if (sp == -2) {
return false;
} else if (sp != -1) {
exit_status = FSL_EXS_CLOSE_TO_SKEL;
exit_data = sp;
stop = true;
break;
} // else if (sp != -1)
} // else
// Check if we are close to a critical point (if lookInCP is true)
// If we are starting from a critical point and we are at the first
// iteration, don't check if we are close to a critical point.
// We may be close to a critical point now, but we may be moving away from
// it at the next step.
if ((originCP != -1) && (first_iteration)) {
// don't check
} // if (originCP != -1) && (first_iteration))
else if (lookInCP) {
cp = closeToCP(startPos, originCP, SP_SMALL_DISTANCE);
if (cp != -1) {
exit_status = FSL_EXS_CLOSE_TO_CP;
exit_data = cp;
stop = true;
break;
} // if (cp != -1)
} // else if (lookInCP)
// Add startPos to the skeleton if not too close to last added point
// for the first iteration. startPos is equal to lastAddedSkelPoint so
// the starting position is not added twice
if (distance(lastAddedSkelPoint, startPos) > SP_SMALL_DISTANCE) {
// Add current position to the skeleton
s = addSkeletonPoint(startPos);
if (s == -2) {
return false;
}
// Update current segment
if (skelSegments[crtSegment][SKEL_SEG_LEFT] == skelSegments[crtSegment][SKEL_SEG_FIRST]) {
// If LEFT and FIRST are the same, make FIRST equal to this new position
skelSegments[crtSegment][SKEL_SEG_FIRST] = s;
}
skelSegments[crtSegment][SKEL_SEG_LAST] = s;
skelSegments[crtSegment][SKEL_SEG_RIGHT] = s;
// Update lastAddedSkelPoint
lastAddedSkelPoint[0] = startPos[0];
lastAddedSkelPoint[1] = startPos[1];
lastAddedSkelPoint[2] = startPos[2];
} // if (distance(lastAddedSkelPoint, startPos) > SP_SMALL_DISTANCE)
// Move to the next position
// For the first iteration, the next position is given by the
// whereTo vector, if it's not null. If it is null, then we take
// the force field value at the start position
if (first_iteration) {
first_iteration = false;
if (whereTo != null) {
nextPos[0] = startPos[0] + (whereTo[0] * STEP_SIZE);
nextPos[1] = startPos[1] + (whereTo[1] * STEP_SIZE);
nextPos[2] = startPos[2] + (whereTo[2] * STEP_SIZE);
} else {
rk2(startPos[0], startPos[1], startPos[2], STEP_SIZE, nextPos);
}
} // if (first_iteration)
else {
// For the subsequent iterations, we use the vector field value
// at the current position
rk2(startPos[0], startPos[1], startPos[2], STEP_SIZE, nextPos);
} // else not first_iteration
// If nextPos = startPos we are stuck and should stop
if (((nextPos[0] - startPos[0]) < EPSILON) && ((nextPos[0] - startPos[0]) > -EPSILON) &&
((nextPos[1] - startPos[1]) < EPSILON) && ((nextPos[1] - startPos[1]) > -EPSILON) &&
((nextPos[2] - startPos[2]) < EPSILON) && ((nextPos[2] - startPos[2]) > -EPSILON)) {
exit_status = FSL_EXS_STUCK;
stop = true;
break;
}
// Next position becomes current position
startPos[0] = nextPos[0];
startPos[1] = nextPos[1];
startPos[2] = nextPos[2];
first_iteration = false;
} // while (!stop)
// Usually, if the current segment is not long enough
// we are not going to keep it.
// However, if the segment originated in a critical point, we should
// keep it regardless of length. Removing it might disconnect the skeleton.
// Check segment length only if not originated at a critical point
if (originCP == -1) {
if (!segmentIsLongEnough(crtSegment)) {
// The segment is not long enough - will be removed
deleteLastSkelSegment();
// Also delete the points added to the skeleton during the processing of
// this segment
skelNumPoints = nrAlreadyInSkel;
return true;
}
} // if (originCP == -1)
// We are going to keep the segment; let's finish the job
switch (exit_status) {
case FSL_EXS_TOO_MANY_STEPS:
// nothing to do
break;
case FSL_EXS_CLOSE_TO_SKEL:
// We are close to a skeleton point, belonging to another segment
// End the current segment at the intersection point
skelSegments[crtSegment][SKEL_SEG_RIGHT] = exit_data;
// Find the segment that contains the skeleton point we are close to
// (that segment will be split into 2 if we are not close to one of
// its end points)
endPoint[0] = false;
segToBeSplit = getSkelSegment(exit_data, endPoint);
if (segToBeSplit == -2) {
return false;
}
if (!endPoint[0]) {
// Not close to one of the end points - the segment must be split
// Create a new skeleton segment starting at the intersection point
// and ending where the original segment ended.
newSeg = addNewSkelSegment(exit_data);
if (newSeg == -2) {
return false;
}
// LEFT and FIRST are set to exit_data by addNewSkelSegment
skelSegments[newSeg][SKEL_SEG_RIGHT] = skelSegments[segToBeSplit][SKEL_SEG_RIGHT];
skelSegments[newSeg][SKEL_SEG_LAST] = skelSegments[segToBeSplit][SKEL_SEG_LAST];
// The old segment now has to terminate at the intersection point
skelSegments[segToBeSplit][SKEL_SEG_RIGHT] = exit_data;
skelSegments[segToBeSplit][SKEL_SEG_LAST] = exit_data;
} // if (!endPoint[0])
else {
// We are close to one of the end points of an existing segment
// The original segment doesn't have to be split
} // else
break;
case FSL_EXS_CLOSE_TO_CP:
// We are close to a critical point that is not in the skeleton yet.
// (We know it's not in the skeleton yet because we first check if
// we are close to a skeleton point, and only if we are not close
// to any skeleton point do we check whether we are close to a critical
// point)
// Add the critical point to the skeleton
sp = addSkeletonPoint(critPts[exit_data]);
if (sp == -2) {
return false;
}
// Mark the critical point as being part of the skeleton
critPtInSkeleton[exit_data] = sp;
// End the current segment at the critical point
skelSegments[crtSegment][SKEL_SEG_RIGHT] = sp;
break;
case FSL_EXS_STUCK:
// We are stuck in a place - nothing to do, just exit
break;
case FSL_EXS_OUTSIDE:
// The segment touched the bounding box.
// The segment will be removed
deleteLastSkelSegment();
// Also delete the points added to the skeleton during the processing
// of this segment
skelNumPoints = nrAlreadyInSkel;
break;
case FSL_EXS_ERROR:
MipavUtil.displayError("follow stream lines exit status error");
return false;
} // switch(exit_status)
return true;
} // followStreamLines
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean getCriticalPoints() {
int idx;
int x, y, z, ii;
double vecLength;
double[] critpt = new double[3];
int[] inds = new int[27];
boolean skipThisPoint = false;
double[][] cv;
double vdist;
int i;
double[][] jac;
Matrix jacMatrix;
EigenvalueDecomposition eig;
double[] realEigen;
double[][] eigenvec;
try {
critPts = new double[MAX_NUM_CRITPTS][3];
pointType = new byte[MAX_NUM_CRITPTS];
// 3 eigenvalues and 3 eigenvectors of the Jacobian matrix are evaluated at the
// critical point
realEigenvalues = new double[MAX_NUM_CRITPTS][3];
// 3 double values for each vector
eigenvectors = new double[MAX_NUM_CRITPTS][3][3];
} catch (OutOfMemoryError e) {
MipavUtil.displayError("Error allocating critical point memory");
return false;
}
numCritPoints = 0;
for (z = 1; z < (zDim - 1); z++) {
Preferences.debug("Processing plane " + z + " out of " + (zDim - 1) + "\n");
for (y = 1; y < (yDim - 1); y++) {
for (x = 1; x < (xDim - 1); x++) {
idx = (z * sliceSize) + (y * xDim) + x;
// Ignore voxels that are BOUNDARY or SURF or have a neighbor that is
// Also, ignore voxels that are EXTERIOR or have a neighbor that is
// We have to check the neighbors that will be touched by the interpolation
// The flags array indicates the state of all the face neighbors,
// but we are not interested in all the face neighbors,
// just 3 of them, so will will not be using the flag SURF or BOUNDARY
// at the current point to find out if it has any external neighbors.
// These are the neighbors that will be touched by the interpolation
inds[0] = idx;
inds[1] = idx + 1;
inds[2] = idx + xDim;
inds[3] = idx + xDim + 1;
inds[4] = idx + sliceSize;
inds[5] = idx + sliceSize + 1;
inds[6] = idx + sliceSize + xDim;
inds[7] = idx + sliceSize + xDim + 1;
skipThisPoint = false;
for (ii = 0; ii < 8; ii++) {
// Ignore voxels close to the boundary
if (ii > 0) {
if ((vol[inds[ii]] == SURF) || (vol[inds[ii]] == BOUNDARY)) {
skipThisPoint = true;
break;
}
} // if (ii > 0)
// Ignore voxels on the boundary (neighbor to an exterior point)
// or in the exterior
if (vol[inds[ii]] == EXTERIOR) {
skipThisPoint = true;
break;
}
} // for (ii = 0; ii < 8; ii++)
if (skipThisPoint) {
continue;
}
if (findCriticalPointInIntCell(x, y, z, inds, critpt)) {
critPts[numCritPoints][0] = critpt[0];
critPts[numCritPoints][1] = critpt[1];
critPts[numCritPoints][2] = critpt[2];
pointType[numCritPoints] = CPT_UNKNOWN;
numCritPoints++;
if (numCritPoints >= MAX_NUM_CRITPTS) {
MipavUtil.displayError("Too many critical points found");
return false;
}
} // if (findCriticalPointInIntCell(x, y, z, inds, critPt))
} // for (x = 1; x < xDim-1; x++)
} // for (y = 1; y < yDim-1; y++)
} // for (z = 1; z < zDim-1; z++)
Preferences.debug("Number of critical points is: " + numCritPoints + "\n");
// Classify the critical points as: attracting nodes, repelling nodes, or
// saddles.
cv = new double[6][3];
// distance to a neighbor will be 1/CELL_SUBDIVISION_FACTOR
vdist = 1.0 / CELL_SUBDIVISION_FACTOR;
jac = new double[3][3];
// Since critical points are at least 1 voxel inside the bounding box,
// we will not check that the neighbor coordinates are inside the
// volume bounds, because they should be.
for (i = 0; i < numCritPoints; i++) {
// Interpolate the force vector at 6 neighbors of this point
cv[0] = interpolation(critPts[i][0] + vdist, critPts[i][1], critPts[i][2]);
cv[1] = interpolation(critPts[i][0] - vdist, critPts[i][1], critPts[i][2]);
cv[2] = interpolation(critPts[i][0], critPts[i][1] + vdist, critPts[i][2]);
cv[3] = interpolation(critPts[i][0], critPts[i][1] - vdist, critPts[i][2]);
cv[4] = interpolation(critPts[i][0], critPts[i][1], critPts[i][2] + vdist);
cv[5] = interpolation(critPts[i][0], critPts[i][1], critPts[i][2] - vdist);
// Construct the Jacobian matrix
// is central differencing ok ???
jac[0][0] = (cv[0][0] - cv[1][0]) / (2.0 * vdist);
jac[0][1] = (cv[2][0] - cv[3][0]) / (2.0 * vdist);
jac[0][2] = (cv[4][0] - cv[5][0]) / (2.0 * vdist);
jac[1][0] = (cv[0][1] - cv[1][1]) / (2.0 * vdist);
jac[1][1] = (cv[2][1] - cv[3][1]) / (2.0 * vdist);
jac[1][2] = (cv[4][1] - cv[5][1]) / (2.0 * vdist);
jac[2][0] = (cv[0][2] - cv[1][2]) / (2.0 * vdist);
jac[2][1] = (cv[2][2] - cv[3][2]) / (2.0 * vdist);
jac[2][2] = (cv[4][2] - cv[5][2]) / (2.0 * vdist);
// Find the eigenvalues and eigenvectors of the Jacobian
jacMatrix = new Matrix(jac);
eig = new EigenvalueDecomposition(jacMatrix);
realEigen = eig.getRealEigenvalues();
// The columns of eigenvec represent the eigenvectors
eigenvec = eig.getV().getArray();
// Analyze the eigenvalues
// If all real parts of the eigenvalues are negative, the point is an attracting node.
if ((realEigen[0] < 0.0) && (realEigen[1] < 0.0) && (realEigen[2] < 0.0)) {
pointType[i] = CPT_ATTRACTING_NODE;
}
// If all real parts of the eigenvalues are positive, the point is a repelling node.
else if ((realEigen[0] > 0.0) && (realEigen[1] > 0.0) && (realEigen[2] > 0.0)) {
pointType[i] = CPT_REPELLING_NODE;
}
// else if 2 real parts of the eigenvalues are of one sign and the other
// has the opposite sign, the point is a saddle point
else {
pointType[i] = CPT_SADDLE;
}
realEigenvalues[i][0] = realEigen[0];
realEigenvalues[i][1] = realEigen[1];
realEigenvalues[i][2] = realEigen[2];
// Normalize the eigenvectors
vecLength = Math.sqrt((eigenvec[0][0] * eigenvec[0][0]) + (eigenvec[1][0] * eigenvec[1][0]) +
(eigenvec[2][0] * eigenvec[2][0]));
if (vecLength == 0.0) {
vecLength = 1.0;
}
eigenvectors[i][0][0] = eigenvec[0][0] / vecLength;
eigenvectors[i][0][1] = eigenvec[1][0] / vecLength;
eigenvectors[i][0][2] = eigenvec[2][0] / vecLength;
vecLength = Math.sqrt((eigenvec[0][1] * eigenvec[0][1]) + (eigenvec[1][1] * eigenvec[1][1]) +
(eigenvec[2][1] * eigenvec[2][1]));
if (vecLength == 0.0) {
vecLength = 1.0;
}
eigenvectors[i][1][0] = eigenvec[0][1] / vecLength;
eigenvectors[i][1][1] = eigenvec[1][1] / vecLength;
eigenvectors[i][1][2] = eigenvec[2][1] / vecLength;
vecLength = Math.sqrt((eigenvec[0][2] * eigenvec[0][2]) + (eigenvec[1][2] * eigenvec[1][2]) +
(eigenvec[2][2] * eigenvec[2][2]));
if (vecLength == 0.0) {
vecLength = 1.0;
}
eigenvectors[i][2][0] = eigenvec[0][2] / vecLength;
eigenvectors[i][2][1] = eigenvec[1][2] / vecLength;
eigenvectors[i][2][2] = eigenvec[2][2] / vecLength;
} // for (i = 0; i < numCritPoints; i++)
return true;
} // getCriticalPoints
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean getHighDivergencePoints() {
// Find high divergence points of a vector field
// --- Input: 1. Normalized 3D vector field
//
// divergence = dFx/dx + dFy/dy + dFz/dz
// Output: highest perHDPoints fraction of divergence point list
int idx;
int i, j, k, ii, jj, kk;
double x, y, z;
int cntz, cntnz;
double[] adiv = null;
int[][] groupsPoints = null;
int[] groupsNumPoints = null;
int numGroups = 0;
boolean closeToSomeGroup = false;
double[][] newHDPoints = null;
if (hdPoints != null) {
for (i = 0; i < hdPoints.length; i++) {
hdPoints[i] = null;
}
hdPoints = null;
}
numHDPoints = 0;
try {
adiv = new double[MAX_NUM_HDPTS]; // divergence array
} catch (OutOfMemoryError e) {
MipavUtil.displayError("Error allocating divergence array");
return false;
}
try {
hdPoints = new double[MAX_NUM_HDPTS][3];
} catch (OutOfMemoryError e) {
MipavUtil.displayError("Error allocating hdPoints array");
return false;
}
// Calculate divergence throughout the dataset
double maxDiv = -999999.99;
double minDiv = 999999.99;
double div;
cntz = 0;
cntnz = 0;
double zeroDiv = 0.1;
double[][] v = new double[6][3];
double vdist = CELL_SIZE / 2.0;
double threshold;
double minVal, tmp;
int minPos;
Preferences.debug("Finding high divergence points 1\n");
for (k = 1; k < (zDim - 1); k++) {
for (j = 1; j < (yDim - 1); j++) {
for (i = 1; i < (xDim - 1); i++) {
idx = (k * sliceSize) + (j * xDim) + i;
// If this point is EXTERIOR, BOUNDARY, or SURF, skip it.
if ((vol[idx] == EXTERIOR) || (vol[idx] == BOUNDARY) || (vol[idx] == SURF)) {
continue;
}
for (kk = 0; kk < SEARCH_GRID; kk++) {
z = k + (kk * CELL_SIZE);
for (jj = 0; jj < SEARCH_GRID; jj++) {
y = j + (jj * CELL_SIZE);
for (ii = 0; ii < SEARCH_GRID; ii++) {
x = i + (ii * CELL_SIZE);
// Interpolate force vectors around the point
v[0] = interpolation(x + vdist, y, z);
v[1] = interpolation(x - vdist, y, z);
v[2] = interpolation(x, y + vdist, z);
v[3] = interpolation(x, y - vdist, z);
v[4] = interpolation(x, y, z + vdist);
v[5] = interpolation(x, y, z - vdist);
div = ((v[0][0] - v[1][0]) + (v[2][1] - v[3][1]) + (v[4][2] - v[5][2])) / (2.0 * vdist);
if ((div > -zeroDiv) && (div < zeroDiv)) {
cntz++;
} else {
cntnz++;
}
if (div > maxDiv) {
maxDiv = div;
}
if (div < minDiv) {
minDiv = div;
}
} // for (ii = 0; ii < SEARCH_GRID; ii++)
} // for (jj = 0; jj < SEARCH_GRID; jj++)
} // for (kk = 0; kk < SEARCH_GRID; kk++)
} // for (i = 1; i < xDim-1; i++)
} // for (j = 1; j < yDim-1; j++)
} // for (k = 1; k < zDim-1; k++)
// case 1:
// take perHDPoints fraction of lowest negative value
threshold = maxDiv - minDiv;
threshold = perHDPoints * threshold;
threshold = minDiv + threshold;
Preferences.debug("Finding high divergence points 2\n");
for (k = 1; k < (zDim - 1); k++) {
for (j = 1; j < (yDim - 1); j++) {
for (i = 1; i < (xDim - 1); i++) {
idx = (k * sliceSize) + (j * xDim) + i;
// If this point is EXTERIOR, BOUNDARY, or SURF, skip it
if ((vol[idx] == EXTERIOR) || (vol[idx] == BOUNDARY) || (vol[idx] == SURF)) {
continue;
}
for (kk = 0; kk < SEARCH_GRID; kk++) {
z = k + (kk * CELL_SIZE);
for (jj = 0; jj < SEARCH_GRID; jj++) {
y = j + (jj * CELL_SIZE);
for (ii = 0; ii < SEARCH_GRID; ii++) {
x = i + (ii * CELL_SIZE);
// Interpolate force vectors around the point
v[0] = interpolation(x + vdist, y, z);
v[1] = interpolation(x - vdist, y, z);
v[2] = interpolation(x, y + vdist, z);
v[3] = interpolation(x, y - vdist, z);
v[4] = interpolation(x, y, z + vdist);
v[5] = interpolation(x, y, z - vdist);
div = ((v[0][0] - v[1][0]) + (v[2][1] - v[3][1]) + (v[4][2] - v[5][2])) / (2.0 * vdist);
if (div <= threshold) {
// Add the point to the HD list
hdPoints[numHDPoints][0] = x;
hdPoints[numHDPoints][1] = y;
hdPoints[numHDPoints][2] = z;
adiv[numHDPoints] = div;
numHDPoints++;
if (numHDPoints >= MAX_NUM_HDPTS) {
MipavUtil.displayError("Too many divergence points detected");
MipavUtil.displayError("Reached maximum number of " + MAX_NUM_HDPTS);
return false;
}
} // if (div <= threshold)
} // for (ii = 0; ii < SEARCH_GRID; ii++)
} // for (jj = 0; jj < SEARCH_GRID; jj++)
} // for (kk = 0; kk < SEARCH_GRID; kk++)
} // for (i = 1; i < xDim-1; i++)
} // for (j = 1; j < yDim-1; j++)
} // for (k = 1; k < zDim-1; k++)
// Sort the points on the divergence value
for (i = 0; i < numHDPoints; i++) {
minVal = adiv[i];
minPos = i;
for (j = i + 1; j < numHDPoints; j++) {
if (adiv[j] < minVal) {
minVal = adiv[j];
minPos = j;
}
} // for (j = i+1; j < numHDPoints; j++)
if (minPos != i) {
// Exchange points and div values
tmp = adiv[i];
adiv[i] = adiv[minPos];
adiv[minPos] = tmp;
tmp = hdPoints[i][0];
hdPoints[i][0] = hdPoints[minPos][0];
hdPoints[minPos][0] = tmp;
tmp = hdPoints[i][1];
hdPoints[i][1] = hdPoints[minPos][1];
hdPoints[minPos][1] = tmp;
tmp = hdPoints[i][2];
hdPoints[i][2] = hdPoints[minPos][2];
hdPoints[minPos][2] = tmp;
} // if (minPos != i)
} // for (i = 0; i < numHDPoints; i++)
// Cluster the points
// Algorithm:
// First point creates the first group
// For all the other points:
// If the point is close to an existing group
// add the point to that group
// else
// the point starts a new group
// endif
// endfor
// end
// Initialize data structure
try {
groupsPoints = new int[numHDPoints][numHDPoints];
groupsNumPoints = new int[numHDPoints];
} catch (OutOfMemoryError e) {
MipavUtil.displayError("Out of memory error allocating groups structure");
return false;
}
closeToSomeGroup = false;
// First point creates the first group
groupsPoints[0][0] = 0;
groupsNumPoints[0] = 1;
numGroups = 1;
for (i = 1; i < numHDPoints; i++) {
closeToSomeGroup = false;
for (j = 0; j < numGroups; j++) {
if (pointIsCloseToGroup(i, j, groupsPoints, groupsNumPoints)) {
// Add the point to that group
groupsPoints[j][groupsNumPoints[j]] = i;
groupsNumPoints[j] = groupsNumPoints[j] + 1;
closeToSomeGroup = true;
break;
} // if (pointIsCloseToGroup(i, j, groupsPoints, groupsNumPoints))
} // for (j = 0; j < numGroups; j++)
if (!closeToSomeGroup) {
// Start a new group
groupsPoints[numGroups][0] = i;
groupsNumPoints[numGroups] = 1;
numGroups++;
} // if (!closeToSomeGroup)
} // for (i = 1; i < numHDPoints; i++)
// Return only the first point in each group as the high divergence points
try {
newHDPoints = new double[numGroups][3];
} catch (OutOfMemoryError e) {
MipavUtil.displayError("Out of memory error allocating newHDPoints");
return false;
}
for (i = 0; i < numGroups; i++) {
newHDPoints[i][0] = hdPoints[groupsPoints[i][0]][0];
newHDPoints[i][1] = hdPoints[groupsPoints[i][0]][1];
newHDPoints[i][2] = hdPoints[groupsPoints[i][0]][2];
} // for (i = 0; i < numGroups; i++)
// delete the old array
for (i = 0; i < hdPoints.length; i++) {
hdPoints[i] = null;
}
hdPoints = null;
try {
hdPoints = new double[numGroups][3];
} catch (OutOfMemoryError e) {
MipavUtil.displayError("Out of memory error allocating hdPoints");
return false;
}
for (i = 0; i < numGroups; i++) {
for (j = 0; j < 3; j++) {
hdPoints[i][j] = newHDPoints[i][j];
}
}
numHDPoints = numGroups;
return true;
} // getHighDivergencePoints
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean getLevel1Skeleton() {
// Get basic skeleton (level 1): connects only critical points
int i, j;
double[] whereTo = new double[3];
// critPtInSkeleton indicates if a critical point is already part of the
// skeleton (is in the skelPoints array). If -1, then the point is not yet
// in the skelPoints array. Otherwise, it indicates the point's position in
// the skeleton.
int[] critPtInSkeleton = null;
if (numCritPoints < 1) {
return true;
}
try {
critPtInSkeleton = new int[numCritPoints];
} catch (OutOfMemoryError e) {
MipavUtil.displayError("Error allocating memory for critPtInSkeleton");
return false;
}
// Initialize to -1
for (i = 0; i < numCritPoints; i++) {
critPtInSkeleton[i] = -1;
}
// Follow the streamlines starting at saddles in the direction of the positive
// eigenvector(s) until we are close to one of the skeleton points or a critical
// point, ignoring points in the current segment
for (i = 0; i < numCritPoints; i++) {
// Start to follow force field at saddle points only
if (pointType[i] != CPT_SADDLE) {
continue;
}
// The point is a saddle, so we should go in the direction pointed by
// the positive eigenvectors
for (j = 0; j < 3; j++) {
if (realEigenvalues[i][j] > 0.0) {
// direction given by the eigenvector
whereTo[0] = eigenvectors[i][j][0];
whereTo[1] = eigenvectors[i][j][1];
whereTo[2] = eigenvectors[i][j][2];
if (!followStreamLines(i, true, critPts[i], whereTo, critPtInSkeleton)) {
return false;
}
// the exact opposite of the eigenvector
whereTo[0] = -eigenvectors[i][j][0];
whereTo[1] = -eigenvectors[i][j][1];
whereTo[2] = -eigenvectors[i][j][2];
if (!followStreamLines(i, true, critPts[i], whereTo, critPtInSkeleton)) {
return false;
}
} // if (realEigenvalues[i][j] > 0.0)
} // for (j = 0; j < 3; j++)
} // for (i = 0; i < numCritPoints; i++)
return true;
} // getLevel1Skeleton
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean getLevel2Skeleton() {
int i;
// Adds segments starting at interior high divergence points
if (critPts != null) {
for (i = 0; i < critPts.length; i++) {
critPts[i] = null;
}
critPts = null;
}
numCritPoints = 0;
// Follow the streamlines starting at each high divergence point
// until we are close to one of the already existing skeleton points
// ignoring the points in the current segment
if (hdPoints != null) {
for (i = 0; i < numHDPoints; i++) {
if (!followStreamLines(-1, false, hdPoints[i], null, null)) {
return false;
}
} // for (i = 0; i < numHDPoints; i++)
} // if (hdPoints != null)
return true;
} // getLevel2Skeleton
/**
* DOCUMENT ME!
*
* @param point DOCUMENT ME!
* @param endPoint DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private int getSkelSegment(int point, boolean[] endPoint) {
int i;
for (i = 0; i < skelNumSegments; i++) {
if ((point == skelSegments[i][SKEL_SEG_LEFT]) || (point == skelSegments[i][SKEL_SEG_RIGHT])) {
endPoint[0] = true;
return i;
}
if ((point >= skelSegments[i][SKEL_SEG_FIRST]) && (point <= skelSegments[i][SKEL_SEG_LAST])) {
endPoint[0] = false;
return i;
}
} // (for i = 0; i < skelNumSegments; i++)
MipavUtil.displayError("Could not find point in getSkelSegment");
return -2;
} // getSkelSegment
/**
* DOCUMENT ME!
*
* @param x DOCUMENT ME!
* @param y DOCUMENT ME!
* @param z DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private double[] interpolation(double x, double y, double z) {
double[] forceInterp = new double[3];
double alpha, beta, gamma;
int ix, iy, iz;
ix = (int) x;
iy = (int) y;
iz = (int) z;
alpha = x - ix;
beta = y - iy;
gamma = z - iz;
forceInterp[0] = (forceX[(iz * sliceSize) + (iy * xDim) + ix] * (1.0 - alpha) * (1.0 - beta) * (1.0 - gamma)) +
(forceX[((iz + 1) * sliceSize) + (iy * xDim) + ix] * (1.0 - alpha) * (1.0 - beta) * gamma) +
(forceX[(iz * sliceSize) + ((iy + 1) * xDim) + ix] * (1.0 - alpha) * beta * (1.0 - gamma)) +
(forceX[(iz * sliceSize) + (iy * xDim) + ix + 1] * alpha * (1.0 - beta) * (1.0 - gamma)) +
(forceX[((iz + 1) * sliceSize) + (iy * xDim) + ix + 1] * alpha * (1.0 - beta) * gamma) +
(forceX[(iz * sliceSize) + ((iy + 1) * xDim) + ix + 1] * alpha * beta * (1.0 - gamma)) +
(forceX[((iz + 1) * sliceSize) + ((iy + 1) * xDim) + ix] * (1.0 - alpha) * beta * gamma) +
(forceX[((iz + 1) * sliceSize) + ((iy + 1) * xDim) + ix + 1] * alpha * beta * gamma);
forceInterp[1] = (forceY[(iz * sliceSize) + (iy * xDim) + ix] * (1.0 - alpha) * (1.0 - beta) * (1.0 - gamma)) +
(forceY[((iz + 1) * sliceSize) + (iy * xDim) + ix] * (1.0 - alpha) * (1.0 - beta) * gamma) +
(forceY[(iz * sliceSize) + ((iy + 1) * xDim) + ix] * (1.0 - alpha) * beta * (1.0 - gamma)) +
(forceY[(iz * sliceSize) + (iy * xDim) + ix + 1] * alpha * (1.0 - beta) * (1.0 - gamma)) +
(forceY[((iz + 1) * sliceSize) + (iy * xDim) + ix + 1] * alpha * (1.0 - beta) * gamma) +
(forceY[(iz * sliceSize) + ((iy + 1) * xDim) + ix + 1] * alpha * beta * (1.0 - gamma)) +
(forceY[((iz + 1) * sliceSize) + ((iy + 1) * xDim) + ix] * (1.0 - alpha) * beta * gamma) +
(forceY[((iz + 1) * sliceSize) + ((iy + 1) * xDim) + ix + 1] * alpha * beta * gamma);
forceInterp[2] = (forceZ[(iz * sliceSize) + (iy * xDim) + ix] * (1.0 - alpha) * (1.0 - beta) * (1.0 - gamma)) +
(forceZ[((iz + 1) * sliceSize) + (iy * xDim) + ix] * (1.0 - alpha) * (1.0 - beta) * gamma) +
(forceZ[(iz * sliceSize) + ((iy + 1) * xDim) + ix] * (1.0 - alpha) * beta * (1.0 - gamma)) +
(forceZ[(iz * sliceSize) + (iy * xDim) + ix + 1] * alpha * (1.0 - beta) * (1.0 - gamma)) +
(forceZ[((iz + 1) * sliceSize) + (iy * xDim) + ix + 1] * alpha * (1.0 - beta) * gamma) +
(forceZ[(iz * sliceSize) + ((iy + 1) * xDim) + ix + 1] * alpha * beta * (1.0 - gamma)) +
(forceZ[((iz + 1) * sliceSize) + ((iy + 1) * xDim) + ix] * (1.0 - alpha) * beta * gamma) +
(forceZ[((iz + 1) * sliceSize) + ((iy + 1) * xDim) + ix + 1] * alpha * beta * gamma);
return forceInterp;
} // interpolation
/**
* DOCUMENT ME!
*/
private void makeSolidVolume() {
// Makes the 3D dataset a solid volume
// Fills all the holes in the volume if there are any
// Assigns all object voxels the value OBJECT_VAL and all outside voxels
// 1 of 3 values
int i;
vol = new byte[totLength];
// Replace every object voxel with OBJECT_VAL
// Everything else remains zero
for (i = 0; i < totLength; i++) {
if (volFloat[i] >= minObjectValue) {
vol[i] = OBJECT_VAL;
}
}
volFloat = null;
Preferences.debug("Floodfill z planes\n");
// Floodfill the outside of the object with OUTSIDE_1 in the z direction
for (i = 0; i < zDim; i++) {
floodFillZPlane(i);
}
Preferences.debug("Floodfill y planes\n");
// Floodfill the outside of the object with OUTSIDE_2 in the y direction
for (i = 0; i < yDim; i++) {
floodFillYPlane(i);
}
Preferences.debug("floodfill x planes\n");
// Floodfill the outside of the object with OUTSIDE_3 in the x direction
for (i = 0; i < xDim; i++) {
floodFillXPlane(i);
}
// Replace any voxel that's not OUTSIDE_1, OUTSIDE_2, or OUTSIDE_3 with
// INTERIOR and every OUTSIDE_1, OUTSIDE_2, or OUTSIDE_3 with EXTERIOR
for (i = 0; i < totLength; i++) {
if ((vol[i] == OUTSIDE_1) || (vol[i] == OUTSIDE_2) || (vol[i] == OUTSIDE_3)) {
vol[i] = EXTERIOR;
} else {
vol[i] = INTERIOR;
}
} // for (i = 0; i < totLength; i++)
return;
} // makeSolidVolume
/**
* DOCUMENT ME!
*/
private void peelVolume() {
int i;
// Removes the first layer of voxels from the volume
// It may disconnect the volume
// Mark all surface voxels as SURF and then remove them
// Mark all surface voxels as SURF
flagVolume();
// Remove all the surface voxels
for (i = 0; i < totLength; i++) {
if (vol[i] == SURF) {
vol[i] = EXTERIOR;
}
}
return;
} // peelVolume
/**
* DOCUMENT ME!
*
* @param pt DOCUMENT ME!
* @param grp DOCUMENT ME!
* @param groupsPoints DOCUMENT ME!
* @param groupsNumPoints DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean pointIsCloseToGroup(int pt, int grp, int[][] groupsPoints, int[] groupsNumPoints) {
int i;
for (i = 0; i < groupsNumPoints[grp]; i++) {
if ((Math.abs(hdPoints[pt][0] - hdPoints[groupsPoints[grp][i]][0]) <= 1) &&
(Math.abs(hdPoints[pt][1] - hdPoints[groupsPoints[grp][i]][1]) <= 1) &&
(Math.abs(hdPoints[pt][2] - hdPoints[groupsPoints[grp][i]][2]) <= 1)) {
return true;
}
}
return false;
} // pointIsCloseToGroup
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean quickCheckVolumePadding() {
int x, y, z;
int idx;
z = 0;
for (y = 0; y < yDim; y++) {
for (x = 0; x < xDim; x++) {
idx = (z * sliceSize) + (y * xDim) + x;
if (vol[idx] != EXTERIOR) {
return false;
}
}
}
z = zDim - 1;
for (y = 0; y < yDim; y++) {
for (x = 0; x < xDim; x++) {
idx = (z * sliceSize) + (y * xDim) + x;
if (vol[idx] != EXTERIOR) {
return false;
}
}
}
y = 0;
for (z = 0; z < zDim; z++) {
for (x = 0; x < xDim; x++) {
idx = (z * sliceSize) + (y * xDim) + x;
if (vol[idx] != EXTERIOR) {
return false;
}
}
}
y = yDim - 1;
for (z = 0; z < zDim; z++) {
for (x = 0; x < xDim; x++) {
idx = (z * sliceSize) + (y * xDim) + x;
if (vol[idx] != EXTERIOR) {
return false;
}
}
}
x = 0;
for (z = 0; z < zDim; z++) {
for (y = 0; y < yDim; y++) {
idx = (z * sliceSize) + (y * xDim) + x;
if (vol[idx] != EXTERIOR) {
return false;
}
}
}
x = xDim - 1;
for (z = 0; z < zDim; z++) {
for (y = 0; y < yDim; y++) {
idx = (z * sliceSize) + (y * xDim) + x;
if (vol[idx] != EXTERIOR) {
return false;
}
}
}
return true;
} // quickCheckVolumePadding
/**
* DOCUMENT ME!
*
* @param x DOCUMENT ME!
* @param y DOCUMENT ME!
* @param z DOCUMENT ME!
* @param steps DOCUMENT ME!
* @param nextPos DOCUMENT ME!
*/
private void rk2(double x, double y, double z, double steps, double[] nextPos) {
double[] outForce;
double len;
outForce = interpolation(x, y, z);
// normalize
len = Math.sqrt((outForce[0] * outForce[0]) + (outForce[1] * outForce[1]) + (outForce[2] * outForce[2]));
if (len > 0.0) {
outForce[0] = outForce[0] / len;
outForce[1] = outForce[1] / len;
outForce[2] = outForce[2] / len;
}
nextPos[0] = x + (outForce[0] * steps);
nextPos[1] = y + (outForce[1] * steps);
nextPos[2] = z + (outForce[2] * steps);
return;
} // rk2
/**
* DOCUMENT ME!
*
* @param crtSegment DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
private boolean segmentIsLongEnough(int crtSegment) {
// A segment is long enough if it contains minimum MIN_SEG_LENGTH points
// between its left and right end points
if (Math.abs(skelSegments[crtSegment][SKEL_SEG_LAST] - skelSegments[crtSegment][SKEL_SEG_FIRST]) <
MIN_SEG_LENGTH) {
return false;
}
return true;
} // segmentIsLongEnough
/**
* DOCUMENT ME!
*
* @param numBound DOCUMENT ME!
* @param bound DOCUMENT ME!
*/
private void sortBoundaryArray(int numBound, short[][] bound) {
// Sort the boundary array so that we can speed up the potential field calculation:
// zyx in that order
// selection sort
int st, i;
short zvst, yvst;
// sort by Z
sortByZ(0, numBound - 1, bound);
// then by Y
st = 0;
zvst = bound[st][2];
for (i = 0; i < numBound; i++) {
if (bound[i][2] != zvst) {
sortByY(st, i - 1, bound);
st = i;
zvst = bound[st][2];
} // if (bound[i][2] != zvst)
} // for (i = 0; i < numBound; i++)
sortByY(st, numBound - 1, bound);
// then by X
st = 0;
zvst = bound[st][2];
yvst = bound[st][1];
for (i = 0; i < numBound; i++) {
if ((bound[i][1] != yvst) || (bound[i][2] != zvst)) {
sortByX(st, i - 1, bound);
st = i;
zvst = bound[st][2];
yvst = bound[st][1];
} // if ((bound[i][1] != yvst) || (bound[i][2] != zvst))
} // for (i = 0; i < numBound; i++)
sortByX(st, numBound - 1, bound);
return;
} // sortBoundaryArray
/**
* DOCUMENT ME!
*
* @param startAt DOCUMENT ME!
* @param endAt DOCUMENT ME!
* @param bound DOCUMENT ME!
*/
private void sortByX(int startAt, int endAt, short[][] bound) {
int i, j, minIndex, crtMin;
short tmp;
for (i = startAt; i <= endAt; i++) {
minIndex = -1;
crtMin = bound[i][0];
for (j = i + 1; j <= endAt; j++) {
if (bound[j][0] < crtMin) {
minIndex = j;
crtMin = bound[j][0];
} // if (bound[j][0] < crtMin)
} // for (j = i+1; j <= endAt; j++)
if (minIndex != -1) {
// swap values
tmp = bound[i][0];
bound[i][0] = bound[minIndex][0];
bound[minIndex][0] = tmp;
tmp = bound[i][1];
bound[i][1] = bound[minIndex][1];
bound[minIndex][1] = tmp;
tmp = bound[i][2];
bound[i][2] = bound[minIndex][2];
bound[minIndex][2] = tmp;
} // if (minIndex != -1)
} // for (i = startAt; i <= endAt; i++)
return;
} // sortByX
/**
* DOCUMENT ME!
*
* @param startAt DOCUMENT ME!
* @param endAt DOCUMENT ME!
* @param bound DOCUMENT ME!
*/
private void sortByY(int startAt, int endAt, short[][] bound) {
int i, j, minIndex, crtMin;
short tmp;
for (i = startAt; i <= endAt; i++) {
minIndex = -1;
crtMin = bound[i][1];
for (j = i + 1; j <= endAt; j++) {
if (bound[j][1] < crtMin) {
minIndex = j;
crtMin = bound[j][1];
} // if (bound[j][1] < crtMin)
} // for (j = i+1; j <= endAt; j++)
if (minIndex != -1) {
// swap values
tmp = bound[i][0];
bound[i][0] = bound[minIndex][0];
bound[minIndex][0] = tmp;
tmp = bound[i][1];
bound[i][1] = bound[minIndex][1];
bound[minIndex][1] = tmp;
tmp = bound[i][2];
bound[i][2] = bound[minIndex][2];
bound[minIndex][2] = tmp;
} // if (minIndex != -1)
} // for (i = startAt; i <= endAt; i++)
return;
} // sortByY
/**
* DOCUMENT ME!
*
* @param startAt DOCUMENT ME!
* @param endAt DOCUMENT ME!
* @param bound DOCUMENT ME!
*/
private void sortByZ(int startAt, int endAt, short[][] bound) {
int i, j, minIndex, crtMin;
short tmp;
for (i = startAt; i <= endAt; i++) {
minIndex = -1;
crtMin = bound[i][2];
for (j = i + 1; j <= endAt; j++) {
if (bound[j][2] < crtMin) {
minIndex = j;
crtMin = bound[j][2];
}
} // for (j = i+1; j <= endAt; j++)
if (minIndex != -1) {
// swap values
tmp = bound[i][0];
bound[i][0] = bound[minIndex][0];
bound[minIndex][0] = tmp;
tmp = bound[i][1];
bound[i][1] = bound[minIndex][1];
bound[minIndex][1] = tmp;
tmp = bound[i][2];
bound[i][2] = bound[minIndex][2];
bound[minIndex][2] = tmp;
} // if (minIndex != -1)
} // for (i = startAt; i <= endAt; i++)
return;
} // sortByZ
}
| [
"NIH\\mccreedy@ba61647d-9d00-f842-95cd-605cb4296b96"
]
| NIH\mccreedy@ba61647d-9d00-f842-95cd-605cb4296b96 |
f3e9bc0c44714c281afd19f1100ed0e57ad22a1a | a46c469caf66878f566f1f9b1d802731a940c7bd | /samaritan/inject/AbstractBinder.java | f408320e16579b083d19d73ed68b2afd2b5bd52e | []
| no_license | DONGFANG-WANGDAREN/samaritan-1 | 88b6a308d321a90de1bdf57448a4d14879402a2b | 773b7a91ebb4f605e7333eb975c20a0da38e8eaf | refs/heads/master | 2021-12-14T17:54:29.346689 | 2014-12-10T01:52:40 | 2014-12-10T01:52:40 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 516 | java | package samaritan.inject;
import java.util.HashMap;
import java.util.Map;
import samaritan.affirm.Affirm;
abstract class AbstractBinder implements Binder {
private final Map<Class<?>, Binding<?>> bindings = new HashMap<>();
@Override
public void bind(Binding<?> binding) {
Affirm.notNull(binding);
bindings.put(binding.type(), binding);
}
@Override
@SuppressWarnings("unchecked")
public <T, R extends T> R get(Class<T> type) {
Affirm.notNull(type);
return (R) bindings.get(type).get(type);
}
} | [
"[email protected]"
]
| |
a80c9569c49dd6d3873fd9d917165237ce39be27 | 331ff90a88aad3f19f1ce3ff0cee8f951279840f | /src/com/sudoplay/joise/noise/function/Function2DWhite.java | 29407cf0a9a0575a82673d3cef97d06d11e21bad | [
"Zlib",
"Apache-2.0"
]
| permissive | Redexe/Joise | 5c65aa70fd0aa05627c8f853f41d7a7b349573a9 | 13963277662d2e82f2c9e46c76d263ee0f18f6ec | refs/heads/master | 2021-01-21T19:06:36.462931 | 2017-04-02T20:23:01 | 2017-04-02T20:23:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,967 | java | /*
* Copyright (C) 2016 Jason Taylor.
* Released as open-source under the Apache License, Version 2.0.
*
* ============================================================================
* | Joise
* ============================================================================
*
* Copyright (C) 2016 Jason Taylor
*
* 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.
*
* ============================================================================
* | Accidental Noise Library
* | --------------------------------------------------------------------------
* | Joise is a derivative work based on Josua Tippetts' C++ library:
* | http://accidentalnoise.sourceforge.net/index.html
* ============================================================================
*
* Copyright (C) 2011 Joshua Tippetts
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
*
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
*
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
package com.sudoplay.joise.noise.function;
import com.sudoplay.joise.noise.Interpolator;
import com.sudoplay.joise.noise.Noise;
import com.sudoplay.joise.noise.NoiseLUT;
import com.sudoplay.joise.noise.function.spi.Function2D;
import com.sudoplay.util.Bits;
public class Function2DWhite implements
Function2D {
private byte[] buffer;
public Function2DWhite() {
this.buffer = new byte[24];
}
@Override
public double get(double x, double y, long seed, Interpolator interpolator) {
Bits.doubleToByteArray(x, this.buffer, 0);
Bits.doubleToByteArray(y, this.buffer, 8);
Bits.longToByteArray(seed, this.buffer, 16);
int hash = Noise.xorFoldHash(Noise.fnv32ABuf(this.buffer));
return NoiseLUT.whitenoiseLUT[hash];
}
}
| [
"[email protected]"
]
| |
053f607a7b179847635737b6fffb5df729b9e635 | 36698a8464c18cfe4476b954eed4c9f3911b5e2c | /ZimbraSelenium/src/java/com/zimbra/qa/selenium/projects/zcs/tests/briefcase/presentation/PresentationContextMenu.java | 8f992057e638f76ab665a06f902006d61f04a90c | []
| no_license | mcsony/Zimbra-1 | 392ef27bcbd0e0962dce99ceae3f20d7a1e9d1c7 | 4bf3dc250c68a38e38286bdd972c8d5469d40e34 | refs/heads/master | 2021-12-02T06:45:15.852374 | 2011-06-13T13:10:57 | 2011-06-13T13:10:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,618 | java | package com.zimbra.qa.selenium.projects.zcs.tests.briefcase.presentation;
import java.lang.reflect.Method;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import com.zimbra.qa.selenium.framework.core.*;
import com.zimbra.qa.selenium.framework.util.HarnessException;
import com.zimbra.qa.selenium.framework.util.RetryFailedTests;
import com.zimbra.qa.selenium.projects.zcs.tests.CommonTest;
/**
* @author Jitesh Sojitra
*
*/
public class PresentationContextMenu extends CommonTest {
//--------------------------------------------------------------------------
// SECTION 1: DATA-PROVIDERS
//--------------------------------------------------------------------------
@DataProvider(name = "briefcaseDataProvider")
public Object[][] createData(Method method) {
String test = method.getName();
if (test.equals("test1")) {
return new Object[][] { { getLocalizedData_NoSpecialChar() } };
} else {
return new Object[][] { { "" } };
}
}
// --------------
// section 2 BeforeClass
// --------------
@BeforeClass(groups = { "always" })
public void zLogin() throws Exception {
super.NAVIGATION_TAB="briefcase";
super.zLogin();
}
@Test(dataProvider = "briefcaseDataProvider", groups = { "smoke", "full" }, retryAnalyzer = RetryFailedTests.class)
public void test1(String briefcaseName) throws Exception {
if (SelNGBase.isExecutionARetry.get())
handleRetry();
// dummy test
SelNGBase.needReset.set(false);
throw new HarnessException("implement me!");
}
} | [
"[email protected]"
]
| |
0a6717dd9cdc49ff1fe37e48252f0cea22e48521 | 75c4712ae3f946db0c9196ee8307748231487e4b | /src/main/java/com/alipay/api/domain/AntLinkeDevopsMobiledeviceReturnModel.java | b6160c70acf1faac0f8d4762caa65f3b89726530 | [
"Apache-2.0"
]
| permissive | yuanbaoMarvin/alipay-sdk-java-all | 70a72a969f464d79c79d09af8b6b01fa177ac1be | 25f3003d820dbd0b73739d8e32a6093468d9ed92 | refs/heads/master | 2023-06-03T16:54:25.138471 | 2021-06-25T14:48:21 | 2021-06-25T14:48:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 995 | java | package com.alipay.api.domain;
import com.alipay.api.AlipayObject;
import com.alipay.api.internal.mapping.ApiField;
/**
* 虚拟设备释放接口
*
* @author auto create
* @since 1.0, 2021-01-11 13:45:37
*/
public class AntLinkeDevopsMobiledeviceReturnModel extends AlipayObject {
private static final long serialVersionUID = 5658676357518144638L;
/**
* device_id+唯一+设备释放对象+antdevops.mobiledevice.get接口返回参数+必须先占用才能释放
*/
@ApiField("device_id")
private String deviceId;
/**
* access_host+唯一+释放设备的host信息+apply结果返回结果
*/
@ApiField("remote_host")
private String remoteHost;
public String getDeviceId() {
return this.deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getRemoteHost() {
return this.remoteHost;
}
public void setRemoteHost(String remoteHost) {
this.remoteHost = remoteHost;
}
}
| [
"[email protected]"
]
| |
220145274548d2e4314cc9ee77cbb2e3c014512b | 1e212405cd1e48667657045ad91fb4dc05596559 | /lib/openflowj-3.3.0-SNAPSHOT-sources (copy)/org/projectfloodlight/openflow/protocol/OFBsnLuaUploadFlags.java | a12b476f5bd63a32febc8291d704da722779cc46 | [
"Apache-2.0"
]
| permissive | aamorim/floodlight | 60d4ef0b6d7fe68b8b4688f0aa610eb23dd790db | 1b7d494117f3b6b9adbdbcf23e6cb3cc3c6187c9 | refs/heads/master | 2022-07-10T21:50:11.130010 | 2019-09-03T19:02:41 | 2019-09-03T19:02:41 | 203,223,614 | 1 | 0 | Apache-2.0 | 2022-07-06T20:07:15 | 2019-08-19T18:00:01 | Java | UTF-8 | Java | false | false | 1,447 | java | // Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
// Copyright (c) 2011, 2012 Open Networking Foundation
// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
// This library was generated by the LoxiGen Compiler.
// See the file LICENSE.txt which should have been included in the source distribution
// Automatically generated by LOXI from template const.java
// Do not modify
package org.projectfloodlight.openflow.protocol;
import org.projectfloodlight.openflow.protocol.*;
import org.projectfloodlight.openflow.protocol.action.*;
import org.projectfloodlight.openflow.protocol.actionid.*;
import org.projectfloodlight.openflow.protocol.bsntlv.*;
import org.projectfloodlight.openflow.protocol.errormsg.*;
import org.projectfloodlight.openflow.protocol.meterband.*;
import org.projectfloodlight.openflow.protocol.instruction.*;
import org.projectfloodlight.openflow.protocol.instructionid.*;
import org.projectfloodlight.openflow.protocol.match.*;
import org.projectfloodlight.openflow.protocol.stat.*;
import org.projectfloodlight.openflow.protocol.oxm.*;
import org.projectfloodlight.openflow.protocol.oxs.*;
import org.projectfloodlight.openflow.protocol.queueprop.*;
import org.projectfloodlight.openflow.types.*;
import org.projectfloodlight.openflow.util.*;
import org.projectfloodlight.openflow.exceptions.*;
public enum OFBsnLuaUploadFlags {
BSN_LUA_UPLOAD_MORE,
BSN_LUA_UPLOAD_FORCE;
}
| [
"alex@VM-UFS-001"
]
| alex@VM-UFS-001 |
5259975dec0dab1fdae5472dec3f0706df223ce0 | e63363389e72c0822a171e450a41c094c0c1a49c | /Mate20_10_1_0/src/main/java/android/hardware/contexthub/V1_0/IContexthub.java | 0bd68859135723ec96fad8b94fcbfd71cf01405a | []
| no_license | solartcc/HwFrameWorkSource | fc23ca63bcf17865e99b607cc85d89e16ec1b177 | 5b92ed0f1ccb4bafc0fdb08b6fc4d98447b754ad | refs/heads/master | 2022-12-04T21:14:37.581438 | 2020-08-25T04:30:43 | 2020-08-25T04:30:43 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 36,063 | java | package android.hardware.contexthub.V1_0;
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.android.server.BatteryService;
import com.android.server.usb.descriptors.UsbDescriptor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Objects;
public interface IContexthub extends IBase {
public static final String kInterfaceName = "[email protected]::IContexthub";
@Override // android.hidl.base.V1_0.IBase
IHwBinder asBinder();
@Override // android.hidl.base.V1_0.IBase
void debug(NativeHandle nativeHandle, ArrayList<String> arrayList) throws RemoteException;
int disableNanoApp(int i, long j, int i2) throws RemoteException;
int enableNanoApp(int i, long j, int i2) throws RemoteException;
@Override // android.hidl.base.V1_0.IBase
DebugInfo getDebugInfo() throws RemoteException;
@Override // android.hidl.base.V1_0.IBase
ArrayList<byte[]> getHashChain() throws RemoteException;
ArrayList<ContextHub> getHubs() throws RemoteException;
@Override // android.hidl.base.V1_0.IBase
ArrayList<String> interfaceChain() throws RemoteException;
@Override // android.hidl.base.V1_0.IBase
String interfaceDescriptor() throws RemoteException;
@Override // android.hidl.base.V1_0.IBase
boolean linkToDeath(IHwBinder.DeathRecipient deathRecipient, long j) throws RemoteException;
int loadNanoApp(int i, NanoAppBinary nanoAppBinary, int i2) throws RemoteException;
@Override // android.hidl.base.V1_0.IBase
void notifySyspropsChanged() throws RemoteException;
@Override // android.hidl.base.V1_0.IBase
void ping() throws RemoteException;
int queryApps(int i) throws RemoteException;
int registerCallback(int i, IContexthubCallback iContexthubCallback) throws RemoteException;
int sendMessageToHub(int i, ContextHubMsg contextHubMsg) throws RemoteException;
@Override // android.hidl.base.V1_0.IBase
void setHALInstrumentation() throws RemoteException;
@Override // android.hidl.base.V1_0.IBase
boolean unlinkToDeath(IHwBinder.DeathRecipient deathRecipient) throws RemoteException;
int unloadNanoApp(int i, long j, int i2) throws RemoteException;
@Override // android.hidl.base.V1_0.IBase
static default IContexthub asInterface(IHwBinder binder) {
if (binder == null) {
return null;
}
IHwInterface iface = binder.queryLocalInterface(kInterfaceName);
if (iface != null && (iface instanceof IContexthub)) {
return (IContexthub) iface;
}
IContexthub 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;
}
@Override // android.hidl.base.V1_0.IBase
static default IContexthub castFrom(IHwInterface iface) {
if (iface == null) {
return null;
}
return asInterface(iface.asBinder());
}
@Override // android.hidl.base.V1_0.IBase
static default IContexthub getService(String serviceName, boolean retry) throws RemoteException {
return asInterface(HwBinder.getService(kInterfaceName, serviceName, retry));
}
@Override // android.hidl.base.V1_0.IBase
static default IContexthub getService(boolean retry) throws RemoteException {
return getService(BatteryService.HealthServiceWrapper.INSTANCE_VENDOR, retry);
}
@Override // android.hidl.base.V1_0.IBase
static default IContexthub getService(String serviceName) throws RemoteException {
return asInterface(HwBinder.getService(kInterfaceName, serviceName));
}
@Override // android.hidl.base.V1_0.IBase
static default IContexthub getService() throws RemoteException {
return getService(BatteryService.HealthServiceWrapper.INSTANCE_VENDOR);
}
public static final class Proxy implements IContexthub {
private IHwBinder mRemote;
public Proxy(IHwBinder remote) {
this.mRemote = (IHwBinder) Objects.requireNonNull(remote);
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
public IHwBinder asBinder() {
return this.mRemote;
}
public String toString() {
try {
return interfaceDescriptor() + "@Proxy";
} catch (RemoteException e) {
return "[class or subclass of [email protected]::IContexthub]@Proxy";
}
}
public final boolean equals(Object other) {
return HidlSupport.interfacesEqual(this, other);
}
public final int hashCode() {
return asBinder().hashCode();
}
@Override // android.hardware.contexthub.V1_0.IContexthub
public ArrayList<ContextHub> getHubs() throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IContexthub.kInterfaceName);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(1, _hidl_request, _hidl_reply, 0);
_hidl_reply.verifySuccess();
_hidl_request.releaseTemporaryStorage();
return ContextHub.readVectorFromParcel(_hidl_reply);
} finally {
_hidl_reply.release();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub
public int registerCallback(int hubId, IContexthubCallback cb) throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IContexthub.kInterfaceName);
_hidl_request.writeInt32(hubId);
_hidl_request.writeStrongBinder(cb == null ? null : cb.asBinder());
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(2, _hidl_request, _hidl_reply, 0);
_hidl_reply.verifySuccess();
_hidl_request.releaseTemporaryStorage();
return _hidl_reply.readInt32();
} finally {
_hidl_reply.release();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub
public int sendMessageToHub(int hubId, ContextHubMsg msg) throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IContexthub.kInterfaceName);
_hidl_request.writeInt32(hubId);
msg.writeToParcel(_hidl_request);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(3, _hidl_request, _hidl_reply, 0);
_hidl_reply.verifySuccess();
_hidl_request.releaseTemporaryStorage();
return _hidl_reply.readInt32();
} finally {
_hidl_reply.release();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub
public int loadNanoApp(int hubId, NanoAppBinary appBinary, int transactionId) throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IContexthub.kInterfaceName);
_hidl_request.writeInt32(hubId);
appBinary.writeToParcel(_hidl_request);
_hidl_request.writeInt32(transactionId);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(4, _hidl_request, _hidl_reply, 0);
_hidl_reply.verifySuccess();
_hidl_request.releaseTemporaryStorage();
return _hidl_reply.readInt32();
} finally {
_hidl_reply.release();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub
public int unloadNanoApp(int hubId, long appId, int transactionId) throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IContexthub.kInterfaceName);
_hidl_request.writeInt32(hubId);
_hidl_request.writeInt64(appId);
_hidl_request.writeInt32(transactionId);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(5, _hidl_request, _hidl_reply, 0);
_hidl_reply.verifySuccess();
_hidl_request.releaseTemporaryStorage();
return _hidl_reply.readInt32();
} finally {
_hidl_reply.release();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub
public int enableNanoApp(int hubId, long appId, int transactionId) throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IContexthub.kInterfaceName);
_hidl_request.writeInt32(hubId);
_hidl_request.writeInt64(appId);
_hidl_request.writeInt32(transactionId);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(6, _hidl_request, _hidl_reply, 0);
_hidl_reply.verifySuccess();
_hidl_request.releaseTemporaryStorage();
return _hidl_reply.readInt32();
} finally {
_hidl_reply.release();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub
public int disableNanoApp(int hubId, long appId, int transactionId) throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IContexthub.kInterfaceName);
_hidl_request.writeInt32(hubId);
_hidl_request.writeInt64(appId);
_hidl_request.writeInt32(transactionId);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(7, _hidl_request, _hidl_reply, 0);
_hidl_reply.verifySuccess();
_hidl_request.releaseTemporaryStorage();
return _hidl_reply.readInt32();
} finally {
_hidl_reply.release();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub
public int queryApps(int hubId) throws RemoteException {
HwParcel _hidl_request = new HwParcel();
_hidl_request.writeInterfaceToken(IContexthub.kInterfaceName);
_hidl_request.writeInt32(hubId);
HwParcel _hidl_reply = new HwParcel();
try {
this.mRemote.transact(8, _hidl_request, _hidl_reply, 0);
_hidl_reply.verifySuccess();
_hidl_request.releaseTemporaryStorage();
return _hidl_reply.readInt32();
} finally {
_hidl_reply.release();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
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();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
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();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
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();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
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();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
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();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
public boolean linkToDeath(IHwBinder.DeathRecipient recipient, long cookie) throws RemoteException {
return this.mRemote.linkToDeath(recipient, cookie);
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
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();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
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();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
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();
}
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
public boolean unlinkToDeath(IHwBinder.DeathRecipient recipient) throws RemoteException {
return this.mRemote.unlinkToDeath(recipient);
}
}
public static abstract class Stub extends HwBinder implements IContexthub {
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
public IHwBinder asBinder() {
return this;
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
public final ArrayList<String> interfaceChain() {
return new ArrayList<>(Arrays.asList(IContexthub.kInterfaceName, IBase.kInterfaceName));
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
public void debug(NativeHandle fd, ArrayList<String> arrayList) {
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
public final String interfaceDescriptor() {
return IContexthub.kInterfaceName;
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
public final ArrayList<byte[]> getHashChain() {
return new ArrayList<>(Arrays.asList(new byte[]{-91, -82, UsbDescriptor.DESCRIPTORTYPE_BOS, -24, 102, Byte.MAX_VALUE, 11, 26, -16, -101, 19, -25, 45, UsbDescriptor.DESCRIPTORTYPE_HUB, 96, UsbDescriptor.DESCRIPTORTYPE_BOS, 78, -77, -123, 59, UsbDescriptor.DESCRIPTORTYPE_AUDIO_ENDPOINT, 112, 121, -60, 90, -103, -74, -12, -93, 54, 6, 73}, new byte[]{-20, Byte.MAX_VALUE, -41, -98, -48, 45, -6, -123, -68, 73, -108, 38, -83, -82, 62, -66, UsbDescriptor.DESCRIPTORTYPE_PHYSICAL, -17, 5, UsbDescriptor.DESCRIPTORTYPE_AUDIO_INTERFACE, -13, -51, 105, 87, 19, -109, UsbDescriptor.DESCRIPTORTYPE_AUDIO_INTERFACE, -72, 59, 24, -54, 76}));
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
public final void setHALInstrumentation() {
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
public final boolean linkToDeath(IHwBinder.DeathRecipient recipient, long cookie) {
return true;
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
public final void ping() {
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
public final DebugInfo getDebugInfo() {
DebugInfo info = new DebugInfo();
info.pid = HidlSupport.getPidIfSharable();
info.ptr = 0;
info.arch = 0;
return info;
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
public final void notifySyspropsChanged() {
HwBinder.enableInstrumentation();
}
@Override // android.hardware.contexthub.V1_0.IContexthub, android.hidl.base.V1_0.IBase
public final boolean unlinkToDeath(IHwBinder.DeathRecipient recipient) {
return true;
}
public IHwInterface queryLocalInterface(String descriptor) {
if (IContexthub.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;
switch (_hidl_code) {
case 1:
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(IContexthub.kInterfaceName);
ArrayList<ContextHub> _hidl_out_hubs = getHubs();
_hidl_reply.writeStatus(0);
ContextHub.writeVectorToParcel(_hidl_reply, _hidl_out_hubs);
_hidl_reply.send();
return;
case 2:
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(IContexthub.kInterfaceName);
int _hidl_out_result = registerCallback(_hidl_request.readInt32(), IContexthubCallback.asInterface(_hidl_request.readStrongBinder()));
_hidl_reply.writeStatus(0);
_hidl_reply.writeInt32(_hidl_out_result);
_hidl_reply.send();
return;
case 3:
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(IContexthub.kInterfaceName);
int hubId = _hidl_request.readInt32();
ContextHubMsg msg = new ContextHubMsg();
msg.readFromParcel(_hidl_request);
int _hidl_out_result2 = sendMessageToHub(hubId, msg);
_hidl_reply.writeStatus(0);
_hidl_reply.writeInt32(_hidl_out_result2);
_hidl_reply.send();
return;
case 4:
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(IContexthub.kInterfaceName);
int hubId2 = _hidl_request.readInt32();
NanoAppBinary appBinary = new NanoAppBinary();
appBinary.readFromParcel(_hidl_request);
int _hidl_out_result3 = loadNanoApp(hubId2, appBinary, _hidl_request.readInt32());
_hidl_reply.writeStatus(0);
_hidl_reply.writeInt32(_hidl_out_result3);
_hidl_reply.send();
return;
case 5:
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(IContexthub.kInterfaceName);
int _hidl_out_result4 = unloadNanoApp(_hidl_request.readInt32(), _hidl_request.readInt64(), _hidl_request.readInt32());
_hidl_reply.writeStatus(0);
_hidl_reply.writeInt32(_hidl_out_result4);
_hidl_reply.send();
return;
case 6:
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(IContexthub.kInterfaceName);
int _hidl_out_result5 = enableNanoApp(_hidl_request.readInt32(), _hidl_request.readInt64(), _hidl_request.readInt32());
_hidl_reply.writeStatus(0);
_hidl_reply.writeInt32(_hidl_out_result5);
_hidl_reply.send();
return;
case 7:
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(IContexthub.kInterfaceName);
int _hidl_out_result6 = disableNanoApp(_hidl_request.readInt32(), _hidl_request.readInt64(), _hidl_request.readInt32());
_hidl_reply.writeStatus(0);
_hidl_reply.writeInt32(_hidl_out_result6);
_hidl_reply.send();
return;
case 8:
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(IContexthub.kInterfaceName);
int _hidl_out_result7 = queryApps(_hidl_request.readInt32());
_hidl_reply.writeStatus(0);
_hidl_reply.writeInt32(_hidl_out_result7);
_hidl_reply.send();
return;
default:
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;
}
}
}
}
}
| [
"[email protected]"
]
| |
36e2c3b87d9af6a61ee58c0865b870233f32af23 | 81d02689cf4297dd3427bf38de367d0f8753578a | /src/main/java/com/gmail/favorlock/forumbridge/ForumBridgeLogger.java | 384b99c1080fdec2bcdc43a381dafc8c83555189 | []
| no_license | Game-C/Forum-Bridge-1 | 97391495f6df44e06c6bae782aea5bc50d8fcf0e | ad2d81770490ea051b9908af840fb4c8f9c5ae2d | refs/heads/master | 2020-04-01T17:27:49.861180 | 2014-05-12T17:54:11 | 2014-05-12T17:54:11 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,163 | java | package com.gmail.favorlock.forumbridge;
import java.util.logging.Level;
import java.util.logging.Logger;
public class ForumBridgeLogger {
private static Logger log;
private static String prefix;
public static void initialize(Logger newLog) {
ForumBridgeLogger.log = newLog;
prefix = "[" + ForumBridge.name + "] ";
}
public static Logger getLog() {
return log;
}
public static String getPrefix() {
return prefix;
}
public static void setPrefix(String prefix) {
ForumBridgeLogger.prefix = prefix;
}
public static void info(String message) {
log.info(prefix + message);
}
public static void dbinfo(String message) {
log.info(prefix + "[DB] " + message);
}
public static void error(String message) {
log.severe(prefix + message);
}
public static void warning(String message) {
log.warning(prefix + message);
}
public static void config(String message) {
log.config(prefix + message);
}
public static void log(Level level, String message) {
log.log(level, prefix + message);
}
}
| [
"[email protected]"
]
| |
d11b8a6b7cc9c88909597f5640beca273ae8445a | 89af22e28a2a338ce5b06fa6ce24468d267f98db | /myapp/src/main/java/myapp/com/techno/CategoryDAO.java | b30a904a0e716b536534f5a647fd00ee42bdd762 | []
| no_license | GauravGadre123/selectAjax | 2590ac032903ec1870502f967f2d303d30fe1437 | 6c6b66a5302af993c9b34e7d466721c82b4e1532 | refs/heads/master | 2023-01-05T18:14:29.892635 | 2020-11-03T14:00:12 | 2020-11-03T14:00:12 | 309,703,210 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,401 | java | package myapp.com.techno;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
public class CategoryDAO {
private static final String URL = "jdbc:mysql://localhost:3306/order";
private static final String DRIVER = "com.mysql.jdbc.Driver";
private static final String USERNAME = "root";
private static final String PASSWORD = "root";
public static List<Category> list(int id) throws SQLException {
List<Category> listCategory = new ArrayList<Category>();
try {
Class.forName(DRIVER);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Connection connection = DriverManager.getConnection(URL, USERNAME, PASSWORD);
String sql = "SELECT * FROM category where subid="+id;
Statement statement = connection.createStatement();
ResultSet result = statement.executeQuery(sql);
while (result.next()) {
int cid = result.getInt("id");
String name = result.getString("name");
int subid= result.getInt("subid");
Category category = new Category(cid, name,subid);
listCategory.add(category);
}
return listCategory;
}
}
| [
"a@DESKTOP-0T7T504"
]
| a@DESKTOP-0T7T504 |
8f868cf99e4546af6f063424825a835eb3729e10 | f3c52e0c73165481bedbf0dada57a69b8059a8d3 | /src/main/java/net/turtle/math/exception/CalculationException.java | 07b5154de0f37c556af738ea3ffb2a4d193a8766 | [
"Apache-2.0"
]
| permissive | zolv/bignumbers | fce9ac61767282ea8c45d88f1e8c699128ea798e | 47fe52d8098f2601ab0b06d9be38acedf2a57b85 | refs/heads/main | 2022-03-22T13:55:43.820833 | 2022-03-05T22:45:54 | 2022-03-05T22:45:54 | 30,588,024 | 3 | 0 | Apache-2.0 | 2020-08-17T22:31:52 | 2015-02-10T10:56:49 | Java | UTF-8 | Java | false | false | 670 | java | package net.turtle.math.exception;
public class CalculationException extends RuntimeException {
private static final long serialVersionUID = 8730069633079206973L;
public CalculationException() {}
public CalculationException(String message) {
super(message);
}
public CalculationException(Throwable cause) {
super(cause);
}
public CalculationException(String message, Throwable cause) {
super(message, cause);
}
public CalculationException(
String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}
| [
"[email protected]"
]
| |
60ee95bbc2f7649e93a3c70e21ceed7b2e02238f | f2222484c04712b9bc894bfe00ca9c12759f3469 | /src/com/utils/SQLFormatter.java | 7173357804ebfd06a72563fae7a43d21a5a104e9 | []
| no_license | pigV/aaie_server | 8c61638856e3249c79540950f941fe4218322c70 | b73d06c12f0a6db2b179d6722f1fc0f13d79db6c | refs/heads/master | 2021-01-20T21:07:15.943049 | 2017-09-02T08:50:33 | 2017-09-02T08:50:33 | 101,751,683 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,838 | java | package com.utils;
/**
* Created by Administrator on 2017/3/15 0015.
*/
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
import java.util.StringTokenizer;
public class SQLFormatter {
private static final Set<String> BEGIN_CLAUSES = new HashSet<String>();
private static final Set<String> END_CLAUSES = new HashSet<String>();
private static final Set<String> LOGICAL = new HashSet<String>();
private static final Set<String> QUANTIFIERS = new HashSet<String>();
private static final Set<String> DML = new HashSet<String>();
private static final Set<String> MISC = new HashSet<String>();
public static final String WHITESPACE = " \n\r\f\t";
static {
BEGIN_CLAUSES.add( "left" );
BEGIN_CLAUSES.add( "right" );
BEGIN_CLAUSES.add( "inner" );
BEGIN_CLAUSES.add( "outer" );
BEGIN_CLAUSES.add( "group" );
BEGIN_CLAUSES.add( "order" );
END_CLAUSES.add( "where" );
END_CLAUSES.add( "set" );
END_CLAUSES.add( "having" );
END_CLAUSES.add( "join" );
END_CLAUSES.add( "from" );
END_CLAUSES.add( "by" );
END_CLAUSES.add( "join" );
END_CLAUSES.add( "into" );
END_CLAUSES.add( "union" );
LOGICAL.add( "and" );
LOGICAL.add( "or" );
LOGICAL.add( "when" );
LOGICAL.add( "else" );
LOGICAL.add( "end" );
QUANTIFIERS.add( "in" );
QUANTIFIERS.add( "all" );
QUANTIFIERS.add( "exists" );
QUANTIFIERS.add( "some" );
QUANTIFIERS.add( "any" );
DML.add( "insert" );
DML.add( "update" );
DML.add( "delete" );
MISC.add( "select" );
MISC.add( "on" );
}
static final String indentString = " ";
static final String initial = "\n ";
public String format(String source) {
return new FormatProcess( source ).perform();
}
private static class FormatProcess {
boolean beginLine = true;
boolean afterBeginBeforeEnd = false;
boolean afterByOrSetOrFromOrSelect = false;
boolean afterValues = false;
boolean afterOn = false;
boolean afterBetween = false;
boolean afterInsert = false;
int inFunction = 0;
int parensSinceSelect = 0;
private LinkedList<Integer> parenCounts = new LinkedList<Integer>();
private LinkedList<Boolean> afterByOrFromOrSelects = new LinkedList<Boolean>();
int indent = 1;
StringBuilder result = new StringBuilder();
StringTokenizer tokens;
String lastToken;
String token;
String lcToken;
public FormatProcess(String sql) {
tokens = new StringTokenizer(
sql,
"()+*/-=<>'`\"[]," + WHITESPACE,
true
);
}
public String perform() {
result.append( initial );
while ( tokens.hasMoreTokens() ) {
token = tokens.nextToken();
lcToken = token.toLowerCase();
if ( "'".equals( token ) ) {
String t;
do {
t = tokens.nextToken();
token += t;
}
while ( !"'".equals( t ) && tokens.hasMoreTokens() ); // cannot handle single quotes
}
else if ( "\"".equals( token ) ) {
String t;
do {
t = tokens.nextToken();
token += t;
}
while ( !"\"".equals( t ) );
}
if ( afterByOrSetOrFromOrSelect && ",".equals( token ) ) {
commaAfterByOrFromOrSelect();
}
else if ( afterOn && ",".equals( token ) ) {
commaAfterOn();
}
else if ( "(".equals( token ) ) {
openParen();
}
else if ( ")".equals( token ) ) {
closeParen();
}
else if ( BEGIN_CLAUSES.contains( lcToken ) ) {
beginNewClause();
}
else if ( END_CLAUSES.contains( lcToken ) ) {
endNewClause();
}
else if ( "select".equals( lcToken ) ) {
select();
}
else if ( DML.contains( lcToken ) ) {
updateOrInsertOrDelete();
}
else if ( "values".equals( lcToken ) ) {
values();
}
else if ( "on".equals( lcToken ) ) {
on();
}
else if ( afterBetween && lcToken.equals( "and" ) ) {
misc();
afterBetween = false;
}
else if ( LOGICAL.contains( lcToken ) ) {
logical();
}
else if ( isWhitespace( token ) ) {
white();
}
else {
misc();
}
if ( !isWhitespace( token ) ) {
lastToken = lcToken;
}
}
return result.toString();
}
private void commaAfterOn() {
out();
indent--;
newline();
afterOn = false;
afterByOrSetOrFromOrSelect = true;
}
private void commaAfterByOrFromOrSelect() {
out();
newline();
}
private void logical() {
if ( "end".equals( lcToken ) ) {
indent--;
}
newline();
out();
beginLine = false;
}
private void on() {
indent++;
afterOn = true;
newline();
out();
beginLine = false;
}
private void misc() {
out();
if ( "between".equals( lcToken ) ) {
afterBetween = true;
}
if ( afterInsert ) {
newline();
afterInsert = false;
}
else {
beginLine = false;
if ( "case".equals( lcToken ) ) {
indent++;
}
}
}
private void white() {
if ( !beginLine ) {
result.append( " " );
}
}
private void updateOrInsertOrDelete() {
out();
indent++;
beginLine = false;
if ( "update".equals( lcToken ) ) {
newline();
}
if ( "insert".equals( lcToken ) ) {
afterInsert = true;
}
}
@SuppressWarnings( {"UnnecessaryBoxing"})
private void select() {
out();
indent++;
newline();
parenCounts.addLast( Integer.valueOf( parensSinceSelect ) );
afterByOrFromOrSelects.addLast( Boolean.valueOf( afterByOrSetOrFromOrSelect ) );
parensSinceSelect = 0;
afterByOrSetOrFromOrSelect = true;
}
private void out() {
result.append( token );
}
private void endNewClause() {
if ( !afterBeginBeforeEnd ) {
indent--;
if ( afterOn ) {
indent--;
afterOn = false;
}
newline();
}
out();
if ( !"union".equals( lcToken ) ) {
indent++;
}
newline();
afterBeginBeforeEnd = false;
afterByOrSetOrFromOrSelect = "by".equals( lcToken )
|| "set".equals( lcToken )
|| "from".equals( lcToken );
}
private void beginNewClause() {
if ( !afterBeginBeforeEnd ) {
if ( afterOn ) {
indent--;
afterOn = false;
}
indent--;
newline();
}
out();
beginLine = false;
afterBeginBeforeEnd = true;
}
private void values() {
indent--;
newline();
out();
indent++;
newline();
afterValues = true;
}
@SuppressWarnings( {"UnnecessaryUnboxing"})
private void closeParen() {
parensSinceSelect--;
if ( parensSinceSelect < 0 ) {
indent--;
parensSinceSelect = parenCounts.removeLast().intValue();
afterByOrSetOrFromOrSelect = afterByOrFromOrSelects.removeLast().booleanValue();
}
if ( inFunction > 0 ) {
inFunction--;
out();
}
else {
if ( !afterByOrSetOrFromOrSelect ) {
indent--;
newline();
}
out();
}
beginLine = false;
}
private void openParen() {
if ( isFunctionName( lastToken ) || inFunction > 0 ) {
inFunction++;
}
beginLine = false;
if ( inFunction > 0 ) {
out();
}
else {
out();
if ( !afterByOrSetOrFromOrSelect ) {
indent++;
newline();
beginLine = true;
}
}
parensSinceSelect++;
}
private static boolean isFunctionName(String tok) {
final char begin = tok.charAt( 0 );
final boolean isIdentifier = Character.isJavaIdentifierStart( begin ) || '"' == begin;
return isIdentifier &&
!LOGICAL.contains( tok ) &&
!END_CLAUSES.contains( tok ) &&
!QUANTIFIERS.contains( tok ) &&
!DML.contains( tok ) &&
!MISC.contains( tok );
}
private static boolean isWhitespace(String token) {
return WHITESPACE.indexOf( token ) >= 0;
}
private void newline() {
result.append( "\n" );
for ( int i = 0; i < indent; i++ ) {
result.append( indentString );
}
beginLine = true;
}
}
public static void main(String[] args) {
String sql = new SQLFormatter().format("select * from t_sss");
System.out.println(sql);
}
}
| [
"[email protected]"
]
| |
eb8ed141f46da4a697d3901e1a4fbf5687ccf148 | 4da9097315831c8639a8491e881ec97fdf74c603 | /src/StockIT-v1-release_source_from_JADX/sources/com/google/android/exoplayer2/source/chunk/SingleSampleMediaChunk.java | ad581393946bc6d8f1b046f80e3b83515f478eed | [
"Apache-2.0"
]
| permissive | atul-vyshnav/2021_IBM_Code_Challenge_StockIT | 5c3c11af285cf6f032b7c207e457f4c9a5b0c7e1 | 25c26a4cc59a3f3e575f617b59acc202ee6ee48a | refs/heads/main | 2023-08-11T06:17:05.659651 | 2021-10-01T08:48:06 | 2021-10-01T08:48:06 | 410,595,708 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,391 | java | package com.google.android.exoplayer2.source.chunk;
import com.google.android.exoplayer2.C1379C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.extractor.DefaultExtractorInput;
import com.google.android.exoplayer2.extractor.TrackOutput;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DataSpec;
import com.google.android.exoplayer2.util.Util;
import java.io.IOException;
public final class SingleSampleMediaChunk extends BaseMediaChunk {
private boolean loadCompleted;
private long nextLoadPosition;
private final Format sampleFormat;
private final int trackType;
public void cancelLoad() {
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public SingleSampleMediaChunk(DataSource dataSource, DataSpec dataSpec, Format format, int i, Object obj, long j, long j2, long j3, int i2, Format format2) {
super(dataSource, dataSpec, format, i, obj, j, j2, C1379C.TIME_UNSET, C1379C.TIME_UNSET, j3);
this.trackType = i2;
this.sampleFormat = format2;
}
public boolean isLoadCompleted() {
return this.loadCompleted;
}
/* JADX INFO: finally extract failed */
public void load() throws IOException, InterruptedException {
try {
long open = this.dataSource.open(this.dataSpec.subrange(this.nextLoadPosition));
if (open != -1) {
open += this.nextLoadPosition;
}
DefaultExtractorInput defaultExtractorInput = new DefaultExtractorInput(this.dataSource, this.nextLoadPosition, open);
BaseMediaChunkOutput output = getOutput();
output.setSampleOffsetUs(0);
TrackOutput track = output.track(0, this.trackType);
track.format(this.sampleFormat);
for (int i = 0; i != -1; i = track.sampleData(defaultExtractorInput, Integer.MAX_VALUE, true)) {
this.nextLoadPosition += (long) i;
}
track.sampleMetadata(this.startTimeUs, 1, (int) this.nextLoadPosition, 0, (TrackOutput.CryptoData) null);
Util.closeQuietly((DataSource) this.dataSource);
this.loadCompleted = true;
} catch (Throwable th) {
Util.closeQuietly((DataSource) this.dataSource);
throw th;
}
}
}
| [
"[email protected]"
]
| |
56d01f4d55f31791cd16a22c4ee166abcaf968d7 | 07d9645323a7c8fa20d2eade57cc4e6aa727c303 | /exo1/src/exo1/Etape.java | 78bd0ad6b1d217adaee427ea8c9a0f076f9772aa | []
| no_license | FBibonne/exos-java-8-12 | 83a31c01da427b6aea216db3ec21b7572d0a5b54 | 7c1c3124477912e743334905badb5e7590b17ed2 | refs/heads/master | 2020-12-07T19:13:40.223130 | 2020-01-10T15:29:56 | 2020-01-10T15:29:56 | 232,778,164 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 66 | java | package exo1;
public interface Etape {
public void test();
}
| [
"[email protected]"
]
| |
45ed318df9cda178169351ba0486cba6c7e79060 | 95ea0717f5e9490549615d4fe95ac69e1e3dc0c5 | /main/java/org/example/vaccinationapp/MainActivity.java | 6ddf17e3bf74b3b52fae61259bbdc63f3abc4640 | []
| no_license | kapppa69/Navigation-Drawer | ef47594f9edd8ccabfc2b1ea02bb37e3bc41faa5 | 8620bcdfa344a0a91a03decb084d491a7c4cd84a | refs/heads/master | 2022-04-11T02:54:31.998281 | 2020-04-01T15:19:43 | 2020-04-01T15:19:43 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,483 | java | package org.example.vaccinationapp;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import androidx.appcompat.widget.Toolbar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.app.ActionBarDrawerToggle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import com.google.android.material.internal.NavigationMenuPresenter;
import com.google.android.material.navigation.NavigationView;
import org.example.vaccinationapp.R;
public class MainActivity extends AppCompatActivity {
private DrawerLayout mDrawer;
private Toolbar toolbar;
private NavigationView nvDrawer;
//DrawerLayout drawer;
//NavigationView navigationView;
FrameLayout frameLayout;
ActionBarDrawerToggle toggle;
//Toolbar toolbar;
// Make sure to be using androidx.appcompat.app.ActionBarDrawerToggle version.
private ActionBarDrawerToggle drawerToggle;
private int mSelectedId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Set a Toolbar to replace the ActionBar.
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// This will display an Up icon (<-), we will replace it with hamburger later
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Find our drawer view
mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout);
nvDrawer = (NavigationView) findViewById(R.id.nvView);
// Setup drawer view
setupDrawerContent(nvDrawer);
//FragmentManager fragmentManager=new F;
frameLayout = (FrameLayout) findViewById(R.id.flContent);
//View headerLayout = nvDrawer.inflateHeaderView(R.layout.nav_header);
toggle = new ActionBarDrawerToggle(this, mDrawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
mDrawer.addDrawerListener(toggle);
toggle.syncState();
//set default fragment
loadFragment(new Home());
// We can now look up items within the header if needed
// ImageView ivHeaderPhoto = headerLayout.findViewById(R.id.imageView);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// The action bar home/up action should open or close the drawer.
switch (item.getItemId()) {
case android.R.id.home:
mDrawer.openDrawer(GravityCompat.START);
return true;
}
return super.onOptionsItemSelected(item);
}
private void setupDrawerContent(NavigationView navigationView) {
navigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
selectDrawerItem(menuItem);
return true;
}
});
}
public void selectDrawerItem(MenuItem menuItem) {
// Create a new fragment and specify the fragment to show based on nav item clicked
Fragment fragment = null;
Class fragmentClass = null;
switch(menuItem.getItemId()) {
case R.id.childDetails:
fragmentClass = ChildDetails.class;
break;
case R.id.home:
fragmentClass = Home.class;
break;
/* default:
fragmentClass = FirstFragment.class;*/
case R.id.articles:
fragmentClass = Articles.class;
break;
case R.id.logout:
fragmentClass=Home.class;
Intent intent=new Intent(getBaseContext(),Login.class);
startActivity(intent);
break;
case R.id.nearBy:
fragmentClass=Home.class;
Intent i=new Intent(getBaseContext(),MapsActivity.class);
startActivity(i);
break;
default:
fragmentClass = Home.class;;
}
try {
fragment = (Fragment) fragmentClass.newInstance();
} catch (Exception e) {
e.printStackTrace();
}
// Insert the fragment by replacing any existing fragment
FragmentManager fragmentManager = getSupportFragmentManager();
// getFragmentManager().popBackStack();
fragmentManager.beginTransaction().replace(R.id.flContent, fragment).addToBackStack("fragBack").commit();
// Highlight the selected item has been done by NavigationView
menuItem.setChecked(true);
// Set action bar title
setTitle(menuItem.getTitle());
// Close the navigation drawer
mDrawer.closeDrawers();
}
public void loadFragment(Fragment fragment) {
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.flContent, fragment);
transaction.commit();
}
} | [
"[email protected]"
]
| |
0d32132f71d2b79aa62134140f0ef7290c7543e8 | 59ead693fb0c744c9ee2bc30aaad6ac670ae91f4 | /barak_p4/src/TaskItem.java | b631ceb3a2b5a9ea4d8cec4bcde462b83c01c3c2 | []
| no_license | Lior5/COP3330_Barak | b259a6ddd82abd87e27da340df64862a39715b9d | 977e3a92fa4d51f40bd5efb189425f5f03213279 | refs/heads/master | 2023-03-09T14:21:54.348293 | 2021-02-01T23:41:33 | 2021-02-01T23:41:33 | 293,927,884 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,042 | java | public class TaskItem {
private String title, description, dueDate;
private boolean completed = false;
public TaskItem(String title, String description,String dueDate){
this.title = title;
this.description = description;
this.dueDate = dueDate;
}
public boolean get_completed(){
return this.completed;
}
public String get_title(){
return this.title;
}
public String get_description(){
return this.description;
}
public String get_dueDate(){
return this.dueDate;
}
public void set_title(String title){
this.title = title;
}
public void set_description(String description){
this.description = description;
}
public void set_dueDate(String dueDate){
this.dueDate = dueDate;
}
public void mark_completed(){
this.completed = true;
}
public void mark_uncompleted(){
this.completed = false;
}
public void is_valid_title(String in) throws InvalidTitleException {
if(in.length()==0) {
throw new InvalidTitleException();
}
}
public void is_valid_date(String in) throws InvalidDateException {
//months are 1-indexed
int[] days_in_month = {0,31,28,31,30,31,30,31,31,30,31,30,31};
boolean good = true;
if (in.charAt(4) != '-' || in.charAt(7) != '-') good = false;
if (count_hyphen(in) > 2) good = false;
String[] split = in.split("-");
int[] lengths = {4, 2, 2};
for (int i = 0; i < split.length; i++) {
String now = split[i];
if (!all_numbers(now)) good = false;
if (now.length() != lengths[i]) good = false;
}
if(good) {
int year = Integer.parseInt(split[0]);
int month = Integer.parseInt(split[1]);
int day = Integer.parseInt(split[2]);
if (month > 12 || month < 1) good = false;
int cap = days_in_month[month];
//if it's a leap year and we are on february, there are 29 days
if (is_leap_year(year) && month == 2) cap = 29;
if (day < 1 || day > cap) good = false;
}
if(!good){
throw new InvalidDateException();
}
}
public boolean is_leap_year(int in){
if(in%400==0) return true;
if(in%100==0)return false;
if(in%4==0)return true;
return false;
}
public boolean all_numbers(String in){
for(int i = 0;i<in.length();i++){
if(in.charAt(i)<'0' || in.charAt(i)>'9')return false;
}
return true;
}
public int count_hyphen(String in){
int count = 0;
for(int i = 0;i<in.length();i++){
if(in.charAt(i)=='-')count++;
}
return count;
}
}
class InvalidDateException extends Exception{
public InvalidDateException(){
super();
}
}
class InvalidTitleException extends Exception{
public InvalidTitleException(){
super();
}
}
| [
"[email protected]"
]
| |
5edef4c6f2446189140f1037bc5a6e6e06019529 | f18c1835121a0d8de419c9256375a8488680e941 | /Demo_Mybatis02/src/com/demo/entity/Page.java | 414d47d9ea2d9b6cb63e12d2e119e4bcb150bb48 | []
| no_license | maiyuyao/Java | fdc218e347ab30ed0f19cd120178fd198a7e669c | ccbaca9096c78f469d6d1bb73391387a62395c04 | refs/heads/master | 2020-12-15T14:01:17.460556 | 2020-02-14T09:11:49 | 2020-02-14T09:11:49 | 235,127,955 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,725 | java | package com.demo.entity;
/**
* 分页对应的实体类
*/
public class Page {
private int totalNumber; // 总条数
private int currentPage;// 当前第几页
private int totalPage;// 总页数
private int pageNumber = 5;// 每页显示条数
private int mysqlIndex;// Mysql中limit的参数,从第几条开始取
private int mysqlNumber;// Mysql中limit的参数,一共取多少条
private int oracleStart;// Oracle中limit的参数,从第几条开始取
private int oracleEnd;// Oracle中limit的参数,一共取多少条
// 根据当前对象中属性值计算并设置相关属性值
public void count() {
// 计算总页数
int totalPageTemp = this.totalNumber / this.pageNumber;
int plus = (this.totalNumber % this.pageNumber) == 0 ? 0 : 1;
totalPageTemp = totalPageTemp + plus;
if (totalPageTemp <= 0) {
totalPageTemp = 1;
}
this.totalPage = totalPageTemp;
// 设置当前页数
// 总页数小于当前页数,应将当前页数设置为总页数
if (this.totalPage < this.currentPage) {
this.currentPage = this.totalPage;
}
// 当前页数小于1设置为1
if (this.currentPage < 1) {
this.currentPage = 1;
}
// Mysql limit 语法: LIMIT [offset,] rows
this.mysqlIndex = (this.currentPage - 1) * this.pageNumber;
this.mysqlNumber = this.pageNumber;
// Oracle ROWNUM语法: ...ROWNUM <= 10 ) AND ROWNUM > 1
this.oracleStart = (this.currentPage - 1) * this.pageNumber + 1;
this.oracleEnd = this.currentPage * this.pageNumber;
}
public int getTotalNumber() {
return totalNumber;
}
public void setTotalNumber(int totalNumber) {
this.totalNumber = totalNumber;
// 当调用setTotalNumber,自动调用count()方法,计算总页数
this.count();
}
public int getCurrentPage() {
return currentPage;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getPageNumber() {
return pageNumber;
}
public void setPageNumber(int pageNumber) {
this.pageNumber = pageNumber;
this.count();
}
public int getMysqlIndex() {
return mysqlIndex;
}
public void setMysqlIndex(int mysqlIndex) {
this.mysqlIndex = mysqlIndex;
}
public int getMysqlNumber() {
return mysqlNumber;
}
public void setMysqlNumber(int mysqlNumber) {
this.mysqlNumber = mysqlNumber;
}
public int getOracleStart() {
return oracleStart;
}
public void setOracleStart(int oracleStart) {
this.oracleStart = oracleStart;
}
public int getOracleEnd() {
return oracleEnd;
}
public void setOracleEnd(int oracleEnd) {
this.oracleEnd = oracleEnd;
}
}
| [
"maiyuyao.163.com"
]
| maiyuyao.163.com |
68a085b479a416b9378a4a0db88f0f0fcafe3592 | 9ff427d184cbe1c43a06254171e985046de7d249 | /src/main/java/module-info.java | de051065d8ea359a51f3c9bc7db9be3d1632015b | []
| no_license | sai-yi/jfxcontroldemo | 663827d9082083474bbaf041c2326f56a42dbd3b | a5408ab80f6a97a93a51fb554b840e30e771dd1c | refs/heads/master | 2020-08-01T17:10:44.742156 | 2019-09-26T09:55:17 | 2019-09-26T09:55:17 | 211,056,455 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 184 | java | module zero.saiyi.jfxcontroldemo {
requires javafx.controls;
requires javafx.fxml;
opens zero.saiyi.jfxcontroldemo to javafx.fxml;
exports zero.saiyi.jfxcontroldemo;
} | [
"[email protected]"
]
| |
e81a30e2735a5903125d34f67526127f9a828919 | 3e03c1aadf50c42f2f93b91aaf050b2083531a11 | /src/test/java/com/epam/reportportal/jbehave/lifecycle/BeforeScenarioAnnotationFailedTest.java | 5080519dfa4404e6eaf5d4a4a4af5652489deee1 | [
"Apache-2.0"
]
| permissive | reportportal/agent-java-jbehave | fa0862f179a22a15ebedcb43015391b4f8d50718 | a5c6d24941ff04d5241fd8f59ca6992dad28bc2c | refs/heads/develop | 2023-08-21T13:04:22.239770 | 2023-08-04T12:46:30 | 2023-08-04T12:46:30 | 70,480,074 | 8 | 6 | Apache-2.0 | 2023-07-13T10:33:15 | 2016-10-10T11:08:35 | Java | UTF-8 | Java | false | false | 5,687 | java | /*
* Copyright 2021 EPAM Systems
*
* 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.epam.reportportal.jbehave.lifecycle;
import com.epam.reportportal.jbehave.BaseTest;
import com.epam.reportportal.jbehave.ReportPortalStepFormat;
import com.epam.reportportal.jbehave.integration.basic.EmptySteps;
import com.epam.reportportal.jbehave.integration.lifecycle.BeforeScenarioFailedSteps;
import com.epam.reportportal.listeners.ItemStatus;
import com.epam.reportportal.listeners.ItemType;
import com.epam.reportportal.service.Launch;
import com.epam.reportportal.service.ReportPortal;
import com.epam.reportportal.service.ReportPortalClient;
import com.epam.reportportal.util.test.CommonUtils;
import com.epam.ta.reportportal.ws.model.FinishTestItemRQ;
import com.epam.ta.reportportal.ws.model.StartTestItemRQ;
import org.apache.commons.lang3.tuple.Pair;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.mockito.ArgumentMatchers.same;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.*;
public class BeforeScenarioAnnotationFailedTest extends BaseTest {
private final String storyId = CommonUtils.namedId("story_");
private final String beforeStepId = CommonUtils.namedId("before_scenario_step_");
private final String scenarioId = CommonUtils.namedId("scenario_");
private final String stepId = CommonUtils.namedId("step_");
private final List<Pair<String, List<String>>> steps = Collections.singletonList(Pair.of(scenarioId,
Arrays.asList(beforeStepId, stepId)
));
private final ReportPortalClient client = mock(ReportPortalClient.class);
private final ReportPortalStepFormat format = new ReportPortalStepFormat(ReportPortal.create(client,
standardParameters(),
testExecutor()
));
@BeforeEach
public void setupMock() {
mockLaunch(client, null, storyId, steps);
mockBatchLogging(client);
}
private static final String STORY_PATH = "stories/NoScenario.story";
private static final String DEFAULT_SCENARIO_NAME = "No name";
private static final String STEP_NAME = "Given I have empty step";
private static final String BEFORE_SCENARIO_NAME = "beforeScenarioFailed";
@Test
public void verify_before_scenario_annotation_failed_method_reporting() {
run(format, STORY_PATH, new BeforeScenarioFailedSteps(), new EmptySteps());
verify(client).startTestItem(any());
ArgumentCaptor<StartTestItemRQ> startCaptor = ArgumentCaptor.forClass(StartTestItemRQ.class);
verify(client).startTestItem(same(storyId), startCaptor.capture());
verify(client, times(2)).startTestItem(same(scenarioId), startCaptor.capture());
// Start items verification
List<StartTestItemRQ> startItems = startCaptor.getAllValues();
String scenarioCodeRef = STORY_PATH + String.format(SCENARIO_PATTERN, DEFAULT_SCENARIO_NAME);
StartTestItemRQ scenarioStart = startItems.get(0);
assertThat(scenarioStart.getName(), equalTo(DEFAULT_SCENARIO_NAME));
assertThat(scenarioStart.getCodeRef(), equalTo(scenarioCodeRef));
assertThat(scenarioStart.getType(), equalTo(ItemType.SCENARIO.name()));
StartTestItemRQ beforeStep = startItems.get(1);
assertThat(beforeStep.getName(), equalTo(BEFORE_SCENARIO_NAME));
String beforeCodeRef = scenarioCodeRef + String.format(STEP_PATTERN, BEFORE_SCENARIO_NAME);
assertThat(beforeStep.getCodeRef(), equalTo(beforeCodeRef));
assertThat(beforeStep.getType(), equalTo(ItemType.STEP.name()));
StartTestItemRQ step = startItems.get(2);
String stepCodeRef = scenarioCodeRef + String.format(STEP_PATTERN, STEP_NAME);
assertThat(step.getName(), equalTo(STEP_NAME));
assertThat(step.getCodeRef(), equalTo(stepCodeRef));
assertThat(step.getType(), equalTo(ItemType.STEP.name()));
// Finish items verification
ArgumentCaptor<FinishTestItemRQ> finishStepCaptor = ArgumentCaptor.forClass(FinishTestItemRQ.class);
verify(client).finishTestItem(same(beforeStepId), finishStepCaptor.capture());
verify(client).finishTestItem(same(stepId), finishStepCaptor.capture());
verify(client).finishTestItem(same(scenarioId), finishStepCaptor.capture());
verify(client).finishTestItem(same(storyId), finishStepCaptor.capture());
List<FinishTestItemRQ> finishItems = finishStepCaptor.getAllValues();
FinishTestItemRQ beforeStepFinish = finishItems.get(0);
assertThat(beforeStepFinish.getStatus(), equalTo(ItemStatus.FAILED.name()));
assertThat(beforeStepFinish.getIssue(), nullValue());
FinishTestItemRQ stepFinish = finishItems.get(1);
assertThat(stepFinish.getStatus(), equalTo(ItemStatus.SKIPPED.name()));
assertThat(stepFinish.getIssue(), notNullValue());
assertThat(stepFinish.getIssue().getIssueType(), equalTo(Launch.NOT_ISSUE.getIssueType()));
FinishTestItemRQ scenarioFinish = finishItems.get(2);
assertThat(scenarioFinish.getStatus(), equalTo(ItemStatus.FAILED.name()));
FinishTestItemRQ storyFinish = finishItems.get(3);
assertThat(storyFinish.getStatus(), equalTo(ItemStatus.FAILED.name()));
}
}
| [
"[email protected]"
]
| |
b31a7560ccff2b61c967625aa78fcd5a5db08047 | 44cbe0a3963985d8240f25e55f20fc05eed6f2e1 | /rikao3-25/src/main/java/com/bw/rikao3_25/base/BaseActivity.java | 0ea50d35bb21b4301241084c617118322ed8eb17 | []
| no_license | AdminYan/Rikao4 | 4558edee3f36a93bc367a8b76aa616cfd5068d7a | 3709cf9cea9f7e4a25283b11e79d15d7216528c4 | refs/heads/master | 2021-04-07T13:11:51.218774 | 2020-04-02T06:18:07 | 2020-04-02T06:18:07 | 248,678,480 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 651 | java | package com.bw.rikao3_25.base;
import android.os.Bundle;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
//创建activity基类
public abstract class BaseActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//调用抽象方法
setContentView(layoutid());
initView(savedInstanceState);
initData();
}
//创建抽象方法
public abstract void initView(Bundle savedInstanceState);
public abstract void initData();
public abstract int layoutid();
}
| [
"[email protected]"
]
| |
0ccc5f1e5d9d4bf74f83efb79f0d73407f55bbc9 | a40f58080ab90bd4f1ef6292a5b5cf57d77a38d3 | /app/src/main/java/com/example/jayesh/syncsqlitewithserver/RecycleviewAdapter.java | 675f9a7c6fbc85245282958f1cb63b7b5e8b5a11 | []
| no_license | bhatiyajayesh/SyncSqliteWithServer | acfd3c90f2a1aca9af41f5da51443db5bd6bfed1 | 9d59469a3b6f4c5717997046632d1666b03c2a18 | refs/heads/master | 2020-03-12T00:43:20.244554 | 2018-04-20T12:19:46 | 2018-04-20T12:19:46 | 130,206,649 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,763 | java | package com.example.jayesh.syncsqlitewithserver;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
/**
* Created by Jayesh on 19-Apr-18.
*/
public class RecycleviewAdapter extends RecyclerView.Adapter<RecycleviewAdapter.MyViewHolder> {
ArrayList<Contact> contactArrayList = new ArrayList<>();
public RecycleviewAdapter(ArrayList<Contact> contacts) {
this.contactArrayList = contacts;
}
@Override
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row_item, parent, false);
return new MyViewHolder(view);
}
@Override
public void onBindViewHolder(MyViewHolder holder, int position) {
holder.tvName.setText(contactArrayList.get(position).getName());
int sync_status = contactArrayList.get(position).getSync_status();
if (sync_status == DbContact.SYNC_STATUS_OK) {
holder.ivSyncStatus.setImageResource(R.drawable.icon_done);
} else {
holder.ivSyncStatus.setImageResource(R.drawable.icon_sync);
}
}
@Override
public int getItemCount() {
return contactArrayList.size();
}
public static class MyViewHolder extends RecyclerView.ViewHolder {
ImageView ivSyncStatus;
TextView tvName;
public MyViewHolder(View itemView) {
super(itemView);
ivSyncStatus = (ImageView) itemView.findViewById(R.id.ivSync);
tvName = (TextView) itemView.findViewById(R.id.txtName);
}
}
}
| [
"[email protected]"
]
| |
b47e317e990a27e8488a569d97b2c9f374db5499 | dd44c89ab1659a056de18700031fb9e5331c989e | /chin2/src/main/java/NewJFrame.java | 6912d1b89feeeeb33ac75cabef8ae3b4c6912c9b | []
| no_license | ManiKandan051298/netbeans_pro | c7d83850706a30a8fa17c441da36b0738e39e8c0 | 6af3edda05d6b3164af4016f20780879f9456174 | refs/heads/master | 2023-03-27T21:44:11.401387 | 2021-03-31T05:50:32 | 2021-03-31T05:50:32 | 353,240,297 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,218 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author ELCOT
*/
public class NewJFrame extends javax.swing.JFrame {
/**
* Creates new form NewJFrame
*/
public NewJFrame() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 883, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 454, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(NewJFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables
}
| [
"[email protected]"
]
| |
a48066f065e370db8d3219a63c517f1114ead822 | 39563c3c4febf8c17a9dd09a7ced1ab7d03c61da | /app/src/main/java/com/example/camcuz97/nytimessearch/activities/FilterActivity.java | e9fbbfcd8b9bae7dabc10fd7d23e11a03b48c131 | [
"Apache-2.0"
]
| permissive | camcuz97/NYTimesApp | 6af20e1008627f0360492116672b917d09b6a617 | a4004b484cfb694db0f2804cf47bb8abd3a99534 | refs/heads/master | 2021-01-20T19:14:18.654504 | 2016-06-25T01:47:52 | 2016-06-25T01:47:52 | 61,580,642 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,378 | java | package com.example.camcuz97.nytimessearch.activities;
import android.app.DatePickerDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import com.example.camcuz97.nytimessearch.Filters;
import com.example.camcuz97.nytimessearch.R;
import org.parceler.Parcels;
import java.util.Calendar;
import butterknife.BindView;
import butterknife.ButterKnife;
public class FilterActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener{
//binding all views
@BindView(R.id.spSort) Spinner spinner;
@BindView(R.id.cbArts) CheckBox cbArts;
@BindView(R.id.cbStyle) CheckBox cbStyle;
@BindView(R.id.cbSports) CheckBox cbSports;
@BindView(R.id.etDate) EditText etDate;
Calendar cal;
int month; int day; int year;
Filters filter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_filter);
ButterKnife.bind(this);
// Gets filter from SearchActivity
filter = Parcels.unwrap(getIntent().getParcelableExtra("filter"));
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,R.array.strings_array, android.R.layout.simple_spinner_item);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
//Sets up checkboxes and textfields
setViews();
//sets click listener
etDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
cal = Calendar.getInstance();
year = cal.get(Calendar.YEAR);
day = cal.get(Calendar.DATE);
month = cal.get(Calendar.MONTH);
//creates date picker
DatePickerDialog datePicker = new DatePickerDialog(FilterActivity.this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int currYear, int monthOfYear, int dayOfMonth) {
etDate.setText(currYear + "-" + (monthOfYear+1) + "-" + dayOfMonth);
}
}, year,month, day);
datePicker.setTitle("Select Date");
datePicker.show();
}
});
}
private void setViews(){
spinner.setSelection((filter.getSort().equals("Newest")) ? 0 : 1);
cbArts.setChecked((filter.isArts()));
cbSports.setChecked((filter.isSports()));
cbStyle.setChecked((filter.isStyle()));
etDate.setText(filter.getUnchangedDate());
}
// handle the date selected
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
// store the values selected into a Calendar instance
Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, monthOfYear);
c.set(Calendar.DAY_OF_MONTH, dayOfMonth);
}
public void onCheckboxClicked(View view) {
// Is the view now checked?
boolean checked = ((CheckBox) view).isChecked();
// Check which checkbox was clicked
switch(view.getId()) {
//sets filters boolean vals accordingly
case R.id.cbArts:
filter.setArts(checked);
break;
case R.id.cbStyle:
filter.setStyle(checked);
break;
case R.id.cbSports:
filter.setSports(checked);
}
}
public void onSubmit(View view){
//setting filter's values
filter.setSort(spinner.getSelectedItem().toString());
Intent data = new Intent();
filter.setUnchangedDate(etDate.getText().toString());
filter.manipulateDate();
//send filter back and end activity
data.putExtra("filter", Parcels.wrap(filter));
setResult(RESULT_OK, data);
finish();
}
}
| [
"[email protected]"
]
| |
b85eb5e5a2639e4b4d20377008564f4e660556bd | 90780a3a61f8d62f64aa45ab6e6e2d769945e772 | /src/main/java/com/example/mail/entity/User.java | d4737a5eed822167017a71f3bf13a146baf79ec1 | []
| no_license | XHHuiL/MailDemo | 350dd41cdb2841732765df12cdf59c7d0bd11f01 | ee9a60361d285445b23930b87e62621f6ba0c105 | refs/heads/master | 2020-06-13T21:22:31.707843 | 2019-07-03T10:41:08 | 2019-07-03T10:41:08 | 194,791,724 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,948 | java | package com.example.mail.entity;
import java.io.Serializable;
/**
* user
* @author
*/
public class User implements Serializable {
/**
* 用户id
*/
private Integer id;
/**
* 用户名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 电子邮件
*/
private String email;
/**
* 用户激活状态,0表示未激活,1表示激活
*/
private Integer state;
/**
* 激活码
*/
private String code;
private static final long serialVersionUID = 1L;
public User() {
}
public User(String username, String password, String email, Integer state, String code) {
this.username = username;
this.password = password;
this.email = email;
this.state = state;
this.code = code;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public Integer getState() {
return state;
}
public void setState(Integer state) {
this.state = state;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
User other = (User) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getUsername() == null ? other.getUsername() == null : this.getUsername().equals(other.getUsername()))
&& (this.getPassword() == null ? other.getPassword() == null : this.getPassword().equals(other.getPassword()))
&& (this.getEmail() == null ? other.getEmail() == null : this.getEmail().equals(other.getEmail()))
&& (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
&& (this.getCode() == null ? other.getCode() == null : this.getCode().equals(other.getCode()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getUsername() == null) ? 0 : getUsername().hashCode());
result = prime * result + ((getPassword() == null) ? 0 : getPassword().hashCode());
result = prime * result + ((getEmail() == null) ? 0 : getEmail().hashCode());
result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", username=").append(username);
sb.append(", password=").append(password);
sb.append(", email=").append(email);
sb.append(", state=").append(state);
sb.append(", code=").append(code);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
} | [
"[email protected]"
]
| |
a22f94d33b8ecc345eedc89424dbad38aa4aca77 | 144ecb0abd13c5100d3b89082d865282170ccd26 | /inject-java/src/test/groovy/io/micronaut/inject/constructor/mapinjection/A.java | ba3c2f31ef5aa898673559bdb30fd75e0e997ce7 | [
"Apache-2.0"
]
| permissive | micronaut-projects/micronaut-core | 9ef59fca29265a7e949e1434a5de02f6250991f4 | b3056cf10866cceb2bad6f9a35767d50ce566eba | refs/heads/4.1.x | 2023-08-31T11:09:12.094349 | 2023-08-31T10:45:36 | 2023-08-31T10:45:36 | 124,230,204 | 6,271 | 1,256 | Apache-2.0 | 2023-09-14T21:02:48 | 2018-03-07T12:05:08 | Java | UTF-8 | Java | false | false | 680 | java | /*
* Copyright 2017-2020 original 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 io.micronaut.inject.constructor.mapinjection;
public interface A {
}
| [
"[email protected]"
]
| |
dc889b975605319d9e224dafe5616620bb7e0043 | 92f72036f437fb050817582f01ca156d229b4bb2 | /src/kot/kotsnow/ookEditor/Controller.java | e74f091c893d51b78c92047aa6e31a32c76e9b6a | []
| no_license | kodex-snow/edytorOok | 94f183a2733daa255dedbd930c866d63bf0ef97a | 9d1bf159d2e144798e7bb672e105e756e8dc37a1 | refs/heads/master | 2021-01-23T16:51:24.178797 | 2017-06-07T21:07:10 | 2017-06-07T21:07:10 | 93,306,922 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,243 | java | package kot.kotsnow.ookEditor;
import java.io.File;
import java.io.IOException;
import javafx.beans.property.BooleanProperty;
import javafx.fxml.FXML;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.AnchorPane;
import javafx.scene.web.HTMLEditor;
import javafx.stage.FileChooser;
import javafx.stage.Window;
public class Controller
{
@FXML
private HTMLEditor htmlEditor;
@FXML
private MenuItem open;
@FXML
private MenuItem save;
@FXML
private MenuItem exit;
@FXML
private MenuItem settings;
@FXML
private AnchorPane aPane;
private SyntaxHighlighter syntaxHighlighter;
private FileOperationHandler fileOperationHandler;
private FileChooser chooser;
private HtmlTagHandler htmlTagHandler;
public Controller(){
chooser = new FileChooser();
syntaxHighlighter = SyntaxHighlighter.getInstance();
fileOperationHandler = FileOperationHandler.getInstance();
htmlTagHandler = HtmlTagHandler.getInstance();
}
public void initialize(){
try {
htmlEditor.lookup(".top-toolbar").setManaged(false);
htmlEditor.lookup(".top-toolbar").setVisible(false);
htmlEditor.lookup(".bottom-toolbar").setManaged(false);
htmlEditor.lookup(".bottom-toolbar").setVisible(false);
} catch (Exception e) {
e.printStackTrace();
}
}
public void open(){
chooser.setTitle("Open File");
try{
File file = chooser.showOpenDialog(getWindow());
htmlEditor.setHtmlText(fileOperationHandler.open(file));
checkText();
} catch(Exception e){
e.printStackTrace();
}
}
public void save(){
try{
chooser.setTitle("Open File");
File file = chooser.showSaveDialog(getWindow());
fileOperationHandler.save(htmlTagHandler.deleteAllHtmlTags(htmlEditor.getHtmlText()), file);
} catch (Exception e) {
e.printStackTrace();
}
}
public void exit(){
System.exit(0);
}
public void displaySettings() throws IOException, InterruptedException{
SettingsController settingsController = new SettingsController();
settingsController.display();
}
public void checkText(){
htmlEditor.setHtmlText(syntaxHighlighter.highlight(htmlEditor.getHtmlText()));
}
private Window getWindow (){
return htmlEditor.getScene().getWindow();
}
}
| [
"[email protected]"
]
| |
bcdd8db2ea01cfd76737b48b238c0d28bb1a2b0d | 20889c96d7585192a79ab28a8c906b16821644d7 | /src/com/noxlogic/saffire/intellij/plugin/SaffireLanguage.java | ab3e71ee1b23eadd679f3c520b0dffd29b5ef0fb | []
| no_license | jaytaph/saffire-intellij-plugin | e6fbaaa6cbc58d4889dcfb80af355c5de8575dc3 | c6fdc34df254cbdd5154494751e73328d281fac6 | refs/heads/master | 2018-12-29T19:21:23.929439 | 2013-01-18T17:27:58 | 2013-01-18T17:27:58 | 7,689,584 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 271 | java | package com.noxlogic.saffire.intellij.plugin;
import com.intellij.lang.Language;
public class SaffireLanguage extends Language {
public static final SaffireLanguage INSTANCE = new SaffireLanguage();
private SaffireLanguage() {
super("Saffire");
}
} | [
"[email protected]"
]
| |
cc5e82257b39f003cf99f7d7bb641f84f060e008 | 09d0ddd512472a10bab82c912b66cbb13113fcbf | /TestApplications/WhereYouGo-0.9.3-beta/DecompiledCode/JADX/src/main/java/menion/android/whereyougo/preferences/Preferences.java | a8304298f56284604df8ad5799b6a2b58907b8ac | []
| no_license | sgros/activity_flow_plugin | bde2de3745d95e8097c053795c9e990c829a88f4 | 9e59f8b3adacf078946990db9c58f4965a5ccb48 | refs/heads/master | 2020-06-19T02:39:13.865609 | 2019-07-08T20:17:28 | 2019-07-08T20:17:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,990 | java | package menion.android.whereyougo.preferences;
import android.content.Context;
import android.preference.PreferenceManager;
import menion.android.whereyougo.C0254R;
import menion.android.whereyougo.utils.Logger;
import menion.android.whereyougo.utils.Utils;
public class Preferences {
public static int APPEARANCE_FONT_SIZE = 0;
public static boolean APPEARANCE_FULLSCREEN = false;
public static int APPEARANCE_HIGHLIGHT = 0;
public static boolean APPEARANCE_IMAGE_STRETCH = false;
public static boolean APPEARANCE_STATUSBAR = false;
public static int FORMAT_ALTITUDE = 0;
public static int FORMAT_ANGLE = 0;
public static int FORMAT_COO_LATLON = 0;
public static int FORMAT_LENGTH = 0;
public static int FORMAT_SPEED = 0;
public static String GC_PASSWORD = null;
public static String GC_USERNAME = null;
public static boolean GLOBAL_DOUBLE_CLICK = false;
public static int GLOBAL_MAP_PROVIDER = 0;
public static String GLOBAL_ROOT = null;
public static boolean GLOBAL_SAVEGAME_AUTO = false;
public static int GLOBAL_SAVEGAME_SLOTS = 0;
public static boolean GPS = false;
public static double GPS_ALTITUDE_CORRECTION = 0.0d;
public static boolean GPS_BEEP_ON_GPS_FIX = false;
public static boolean GPS_DISABLE_WHEN_HIDE = false;
public static int GPS_MIN_TIME = 0;
public static boolean GPS_START_AUTOMATICALLY = false;
public static boolean GUIDING_GPS_REQUIRED = false;
public static boolean GUIDING_SOUNDS = false;
public static int GUIDING_WAYPOINT_SOUND = 0;
public static String GUIDING_WAYPOINT_SOUND_CUSTOM_SOUND_URI = null;
public static int GUIDING_WAYPOINT_SOUND_DISTANCE = 0;
public static int GUIDING_ZONE_NAVIGATION_POINT = 0;
public static boolean SENSOR_BEARING_TRUE = false;
public static boolean SENSOR_HARDWARE_COMPASS = false;
public static boolean SENSOR_HARDWARE_COMPASS_AUTO_CHANGE = false;
public static int SENSOR_HARDWARE_COMPASS_AUTO_CHANGE_VALUE = 0;
public static int SENSOR_ORIENT_FILTER = 0;
private static final String TAG = "SettingValues";
private static Context prefContext;
public static void setContext(Context c) {
prefContext = c;
}
public static boolean comparePreferenceKey(String prefString, int prefId) {
return prefString.equals(prefContext.getString(prefId));
}
public static String getStringPreference(int PreferenceId) {
return PreferenceManager.getDefaultSharedPreferences(prefContext).getString(prefContext.getString(PreferenceId), "");
}
public static double getDecimalPreference(int PreferenceId) {
return Utils.parseDouble(PreferenceManager.getDefaultSharedPreferences(prefContext).getString(prefContext.getString(PreferenceId), "0.0"));
}
public static int getNumericalPreference(int PreferenceId) {
return Utils.parseInt(PreferenceManager.getDefaultSharedPreferences(prefContext).getString(prefContext.getString(PreferenceId), "0"));
}
public static boolean getBooleanPreference(int PreferenceId) {
return PreferenceManager.getDefaultSharedPreferences(prefContext).getBoolean(prefContext.getString(PreferenceId), false);
}
public static void setStringPreference(int PreferenceId, Object value) {
PreferenceManager.getDefaultSharedPreferences(prefContext).edit().putString(prefContext.getString(PreferenceId), String.valueOf(value)).commit();
}
public static void setPreference(int PreferenceId, String value) {
PreferenceManager.getDefaultSharedPreferences(prefContext).edit().putString(prefContext.getString(PreferenceId), value).commit();
}
public static void setPreference(int PreferenceId, int value) {
PreferenceManager.getDefaultSharedPreferences(prefContext).edit().putInt(prefContext.getString(PreferenceId), value).commit();
}
public static void setPreference(int PreferenceId, float value) {
PreferenceManager.getDefaultSharedPreferences(prefContext).edit().putFloat(prefContext.getString(PreferenceId), value).commit();
}
public static void setPreference(int PreferenceId, boolean value) {
PreferenceManager.getDefaultSharedPreferences(prefContext).edit().putBoolean(prefContext.getString(PreferenceId), value).commit();
}
public static void init(Context c) {
Logger.m20d(TAG, "init(" + c + ")");
try {
GLOBAL_ROOT = getStringPreference(C0254R.string.pref_KEY_S_ROOT);
GLOBAL_MAP_PROVIDER = getNumericalPreference(C0254R.string.pref_KEY_S_MAP_PROVIDER);
GLOBAL_SAVEGAME_AUTO = getBooleanPreference(C0254R.string.pref_KEY_B_SAVEGAME_AUTO);
GLOBAL_SAVEGAME_SLOTS = getNumericalPreference(C0254R.string.pref_KEY_S_SAVEGAME_SLOTS);
GLOBAL_DOUBLE_CLICK = getBooleanPreference(C0254R.string.pref_KEY_B_DOUBLE_CLICK);
GC_USERNAME = getStringPreference(C0254R.string.pref_KEY_S_GC_USERNAME);
GC_PASSWORD = getStringPreference(C0254R.string.pref_KEY_S_GC_PASSWORD);
APPEARANCE_STATUSBAR = getBooleanPreference(C0254R.string.pref_KEY_B_STATUSBAR);
APPEARANCE_FULLSCREEN = getBooleanPreference(C0254R.string.pref_KEY_B_FULLSCREEN);
APPEARANCE_HIGHLIGHT = getNumericalPreference(C0254R.string.pref_KEY_S_HIGHLIGHT);
APPEARANCE_IMAGE_STRETCH = getBooleanPreference(C0254R.string.pref_KEY_B_IMAGE_STRETCH);
APPEARANCE_FONT_SIZE = getNumericalPreference(C0254R.string.pref_KEY_S_FONT_SIZE);
FORMAT_ALTITUDE = getNumericalPreference(C0254R.string.pref_KEY_S_UNITS_ALTITUDE);
FORMAT_ANGLE = getNumericalPreference(C0254R.string.pref_KEY_S_UNITS_ANGLE);
FORMAT_COO_LATLON = getNumericalPreference(C0254R.string.pref_KEY_S_UNITS_COO_LATLON);
FORMAT_LENGTH = getNumericalPreference(C0254R.string.pref_KEY_S_UNITS_LENGTH);
FORMAT_SPEED = getNumericalPreference(C0254R.string.pref_KEY_S_UNITS_SPEED);
GPS = getBooleanPreference(C0254R.string.pref_KEY_B_GPS);
GPS_START_AUTOMATICALLY = getBooleanPreference(C0254R.string.pref_KEY_B_GPS_START_AUTOMATICALLY);
GPS_MIN_TIME = getNumericalPreference(C0254R.string.pref_KEY_S_GPS_MIN_TIME_NOTIFICATION);
GPS_BEEP_ON_GPS_FIX = getBooleanPreference(C0254R.string.pref_KEY_B_GPS_BEEP_ON_GPS_FIX);
GPS_ALTITUDE_CORRECTION = getDecimalPreference(C0254R.string.pref_KEY_S_GPS_ALTITUDE_MANUAL_CORRECTION);
GPS_DISABLE_WHEN_HIDE = getBooleanPreference(C0254R.string.pref_KEY_B_GPS_DISABLE_WHEN_HIDE);
SENSOR_HARDWARE_COMPASS = getBooleanPreference(C0254R.string.pref_KEY_B_SENSOR_HARDWARE_COMPASS);
SENSOR_HARDWARE_COMPASS_AUTO_CHANGE = getBooleanPreference(C0254R.string.pref_KEY_B_HARDWARE_COMPASS_AUTO_CHANGE);
SENSOR_HARDWARE_COMPASS_AUTO_CHANGE_VALUE = getNumericalPreference(C0254R.string.pref_KEY_S_HARDWARE_COMPASS_AUTO_CHANGE_VALUE);
SENSOR_BEARING_TRUE = getBooleanPreference(C0254R.string.pref_KEY_B_SENSORS_BEARING_TRUE);
SENSOR_ORIENT_FILTER = getNumericalPreference(C0254R.string.pref_KEY_S_SENSORS_ORIENT_FILTER);
GUIDING_GPS_REQUIRED = getBooleanPreference(C0254R.string.pref_KEY_B_GUIDING_GPS_REQUIRED);
GUIDING_SOUNDS = getBooleanPreference(C0254R.string.pref_KEY_B_GUIDING_COMPASS_SOUNDS);
GUIDING_WAYPOINT_SOUND = getNumericalPreference(C0254R.string.pref_KEY_S_GUIDING_WAYPOINT_SOUND);
GUIDING_WAYPOINT_SOUND_DISTANCE = getNumericalPreference(C0254R.string.pref_KEY_S_GUIDING_WAYPOINT_SOUND_DISTANCE);
GUIDING_WAYPOINT_SOUND_CUSTOM_SOUND_URI = getStringPreference(C0254R.string.pref_KEY_S_GUIDING_WAYPOINT_SOUND_CUSTOM_SOUND_URI);
GUIDING_ZONE_NAVIGATION_POINT = getNumericalPreference(C0254R.string.pref_KEY_S_GUIDING_ZONE_POINT);
} catch (Exception e) {
Logger.m22e(TAG, "init() - ", e);
}
}
}
| [
"[email protected]"
]
| |
7f9d4b5b2a40068c498d6868af2982b9ed6b10d1 | d00048e2757f2340bb8e529e3f18b400a7d173cd | /src/bt1/builder/HoaDonHeader.java | bac01567a82887f3d42f26460a662a28e94a33f9 | []
| no_license | VoHuuHuy59130929/VoHuuHuy_59130929_CreationalPattern | a28aae6d651006d9e66bd6370d3370bada7ec616 | 177ae2e574049f12fcd28f5d7904ba95a78f3bae | refs/heads/master | 2022-07-07T10:56:08.235571 | 2020-05-13T05:02:14 | 2020-05-13T05:02:14 | 263,527,901 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 873 | java | package builder;
public class HoaDonHeader {
private String maHoaDon, tenKhachHang, ngayBan;
public HoaDonHeader (String maHoaDon, String tenKhachHang, String ngayBan) {
setMaHoaDon(maHoaDon);
setTenKhachHang(tenKhachHang);
setNgayBan(ngayBan);
}
public void setMaHoaDon (String maHoaDon) { this.maHoaDon = maHoaDon; }
public void setTenKhachHang (String tenKhachHang) { this.tenKhachHang = tenKhachHang; }
public void setNgayBan (String ngayBan) { this.ngayBan = ngayBan; }
public String getMaHoaDon () { return this.maHoaDon; }
public String getTenKhachHang () { return this.tenKhachHang; }
public String getNgayBan () { return this.ngayBan; }
@Override
public String toString () {
return "Mã hóa đơn: " + getMaHoaDon() + "\n" +
"Tên khách hàng: " + getTenKhachHang() + "\n" +
"Ngày bán: " + getNgayBan();
}
} | [
"[email protected]"
]
| |
0479463642c7fe81763630f3214408d8b933dd71 | 13954a07622a837ecd2b4b71565cf5e5886bc9a1 | /vocabulary/vocabulary-infrastructure/src/main/java/pl/voclern/vocabulary/adapter/secondary/AddWordModel.java | 14762522cdfefebfa9582fe9e2fbe4fb610fbc36 | []
| no_license | s17179/voclern-app | 07ab1b2725a2fce5f6f925a60b9bbbcca484f6af | e2856a3f3dd107747597fe38fead715525388b76 | refs/heads/master | 2023-02-21T18:47:34.936245 | 2021-01-23T19:16:31 | 2021-01-23T19:16:31 | 320,405,249 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 505 | java | package pl.voclern.vocabulary.adapter.secondary;
import lombok.Getter;
import lombok.Setter;
import pl.voclern.vocabulary.port.primary.contract.AddWordContract;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@Getter
@Setter
class AddWordModel implements AddWordContract {
@NotNull
@Size(min = 1)
private String id;
@NotNull
@Size(min = 1)
private String wordValue;
@NotNull
@Size(min = 1)
private String wordTranslation;
}
| [
"[email protected]"
]
| |
36dc4202c5e6ea4cd67ce80c5df17318e71ccf27 | 9f004c3df4413eb826c229332d95130a1d5c8457 | /src/ankita_assignment_21/Agedifference.java | 85aa9194248e3c51f47d28f85c57ffef63ee0285 | []
| no_license | MayurSTechnoCredit/JAVATechnoJuly2021 | dd8575c800e8f0cac5bab8d5ea32b25f7131dd0d | 3a422553a0d09b6a99e528c73cc2b8efe260a07a | refs/heads/master | 2023-08-22T14:43:37.980748 | 2021-10-16T06:33:34 | 2021-10-16T06:33:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 489 | java | package ankita_assignment_21;
public class Agedifference {
int diffAge(int [] arr) {
int max=arr[0];
int min=arr[0];
for(int index=0;index<arr.length;index++) {
if(arr[index]> max)
max=arr[index];
if(arr[index]< min)
min=arr[index];
}
return max-min;
}
public static void main(String[] args) {
Agedifference age=new Agedifference();
int a[]= {10,34,38,68,72,95,6};
System.out.println("Difference between max & min age is "+ age.diffAge(a));
}
}
| [
"[email protected]"
]
| |
0b6f831ce10ac93fe646eb49af1d1d6e5a234810 | 50c7c873fc63955418ed6bbb90f9d2eddcac721d | /src/main/java/com/cafe24/jblog2/controller/api/UserController.java | d6b7d925fab0a0c24377204ec5dd472f87762255 | []
| no_license | hornedlizard/jblog2 | 2d8d2388381e2921f8197e32888c0e9f8e5d2fc1 | 51586714deee090df1940a12d67f72af2cb44ad7 | refs/heads/master | 2020-03-06T23:37:19.223966 | 2018-04-07T07:59:57 | 2018-04-07T07:59:57 | 127,136,990 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 880 | java | package com.cafe24.jblog2.controller.api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.cafe24.jblog2.dto.JSONResult;
import com.cafe24.jblog2.service.UserService;
import com.cafe24.jblog2.vo.UserVo;
@Controller("userApiController")
@RequestMapping("/api/user")
public class UserController {
@Autowired
private UserService service;
@ResponseBody
@RequestMapping(value="/checkid")
public JSONResult checkId(@RequestParam(value="id", required=true, defaultValue="") String id) {
UserVo vo = service.checkId(id);
return JSONResult.success(vo == null ? "not exist" : "exist");
}
}
| [
"BIT@DESKTOP-A70PMGU"
]
| BIT@DESKTOP-A70PMGU |
4ee166baa93267ef94195acee6eae14d569d5cf7 | 4caa52bc1d522d343ccdd12369c581c9b28f8fde | /src/shape/test/CircleTest.java | b2c709a01fc528816851a9e030c243478bab362b | []
| no_license | truyenho95/JAVA-WBD-Shape | 41870815cbe83877ee9761d4189e0c59838424c9 | 670bd8e67645c780dfae6dde3f872b19ddda21c6 | refs/heads/master | 2020-04-10T11:28:24.794837 | 2018-12-10T10:23:50 | 2018-12-10T10:23:50 | 160,994,661 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 333 | java | package shape.test;
import shape.model.Circle;
public class CircleTest {
public static void main(String[] args) {
Circle circle = new Circle();
System.out.println(circle);
circle = new Circle(3.5);
System.out.println(circle);
circle = new Circle(3.5, "indigo", false);
System.out.println(circle);
}
}
| [
"[email protected]"
]
| |
4184ba5e6394a130dd406468b010aadb61fe45b5 | 1ed0e7930d6027aa893e1ecd4c5bba79484b7c95 | /keiji/source/java/com/vungle/publisher/dh.java | 4da9492d334b3b25188dd0d79a342d57e7e712ab | []
| no_license | AnKoushinist/hikaru-bottakuri-slot | 36f1821e355a76865057a81221ce2c6f873f04e5 | 7ed60c6d53086243002785538076478c82616802 | refs/heads/master | 2021-01-20T05:47:00.966573 | 2017-08-26T06:58:25 | 2017-08-26T06:58:25 | 101,468,394 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 715 | java | package com.vungle.publisher;
import dagger.MembersInjector;
import dagger.a.c;
import dagger.a.d;
/* compiled from: vungle */
public final class dh implements c<dg> {
static final /* synthetic */ boolean a = (!dh.class.desiredAssertionStatus());
private final MembersInjector<dg> b;
public final /* synthetic */ Object get() {
return (dg) d.a(this.b, new dg());
}
private dh(MembersInjector<dg> membersInjector) {
if (a || membersInjector != null) {
this.b = membersInjector;
return;
}
throw new AssertionError();
}
public static c<dg> a(MembersInjector<dg> membersInjector) {
return new dh(membersInjector);
}
}
| [
"[email protected]"
]
| |
31dbae10b2e23dba83a55f0472fe4621ed071483 | 3b5a85ae7304035385ae7925bfc77f58884bf90a | /src/main/java/com/ydt/oa/action/PurchasePlanAction.java | 809ace2bf8867d3d8fbe6b14c811cf9cb078a0d6 | []
| no_license | xfu00013/oa-2 | ccb58af26fa9747e113a7dbf4aac80a30bb86051 | 3da1b1cb97e99fda896f889d97bec0cc234cfa29 | refs/heads/master | 2021-01-19T07:31:07.788830 | 2015-03-04T11:52:44 | 2015-03-04T11:52:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,937 | java | package com.ydt.oa.action;
import java.io.File;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import com.giro.common.action.BaseAction;
import com.giro.common.action.PageAction;
import com.giro.common.dao.Pagination;
import com.giro.common.exception.GiroException;
import com.ydt.oa.bean.AjaxResult;
import com.ydt.oa.dao.PurchasePlanDao;
import com.ydt.oa.entity.Application;
import com.ydt.oa.entity.ApproveFlow;
import com.ydt.oa.entity.ContractDetails;
import com.ydt.oa.entity.Department;
import com.ydt.oa.entity.Material;
import com.ydt.oa.entity.PurchasePlan;
import com.ydt.oa.entity.PurchasePlanDetails;
import com.ydt.oa.entity.User;
import com.ydt.oa.interfaces.ContractAppInterface;
import com.ydt.oa.interfaces.PurchasePlanAppInterface;
import com.ydt.oa.service.ApproveService;
import com.ydt.oa.service.PurchasePlanDetailsService;
import com.ydt.oa.service.PurchasePlanService;
import com.ydt.oa.service.UserService;
/**
* 审批管理Action
* @author caochun
*
*/
public class PurchasePlanAction extends PageAction {
private static final Logger logger = Logger.getLogger(PurchasePlanAction.class);
public boolean buttonFlag = false;
public boolean isButtonFlag() {
return buttonFlag;
}
@Autowired
private ApproveService approveService;
@Autowired
private PurchasePlanAppInterface purchasePlanAppService;
@Autowired
private PurchasePlanDao purchasePlanDao;
@Autowired
private PurchasePlanService purchasePlanService;
private List<PurchasePlanDetails> purchasePlandetails;
private Application application;
private ApproveFlow approveFlow;
private PurchasePlan purchasePlan;
private Pagination pagination;
private List<PurchasePlanDetails> purchasePlanList;
private List<Material> materialList;
private String formAction;
private AjaxResult ajaxResult;
private User user;
private Department department;
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
public Department getDepartment() {
return department;
}
public void setDepartment(Department department) {
this.department = department;
}
public Application getApplication() {
return application;
}
public String getFormAction() {
return formAction;
}
public void setFormAction(String formAction) {
this.formAction = formAction;
}
public List<PurchasePlanDetails> getPurchasePlanList() {
return purchasePlanList;
}
public void setPurchasePlanList(List<PurchasePlanDetails> purchasePlanList) {
this.purchasePlanList = purchasePlanList;
}
public List<Material> getMaterialList() {
return materialList;
}
public void setMaterialList(List<Material> materialList) {
this.materialList = materialList;
}
public void setApplication(Application application) {
this.application = application;
}
public ApproveFlow getApproveFlow() {
return approveFlow;
}
public void setApproveFlow(ApproveFlow approveFlow) {
this.approveFlow = approveFlow;
}
public List<PurchasePlanDetails> getPurchasePlandetails() {
return purchasePlandetails;
}
public void setPurchasePlandetails(List<PurchasePlanDetails> purchasePlandetails) {
this.purchasePlandetails = purchasePlandetails;
}
public Pagination getPagination() {
return pagination;
}
public AjaxResult getAjaxResult() {
return ajaxResult;
}
public void setAjaxResult(AjaxResult ajaxResult) {
this.ajaxResult = ajaxResult;
}
public void setPagination(Pagination pagination) {
this.pagination = pagination;
}
public PurchasePlan getPurchasePlan() {
return purchasePlan;
}
public void setPurchasePlan(PurchasePlan purchasePlan) {
this.purchasePlan = purchasePlan;
}
/**
* 列出所有计划单 分页
* @return
*/
@Action(value = "/purchaseplan/list",
results = { @Result(name = "success", location = "/purchase/purchaseplanlist.jsp", type = "dispatcher")}
)
public String listByPage() {
pagination = purchasePlanService.list(this.getPageNum(),this.getNumPerPage());
return "success";
}
/**
* 显示具体的采购计划单信息
*/
@Action(value = "/purchaseplan/view",
results = { @Result(name = "success", location = "/purchase/purchaseplanbyID.jsp", type = "dispatcher")}
)
public String view() {
if(purchasePlan != null || purchasePlan.getId() != null ){
purchasePlan = purchasePlanService.findById(purchasePlan.getId());
application = approveService.findByApplyNo("PURCHASEPLAN", purchasePlan.getId());
}
return "success";
}
/**
* 根据采购计划单查出明细
* @return
*/
@Action(value = "/purchaseplanbyID/list",
results = { @Result(name = "success", location = "/purchase/purchaseplandetailsbyID.jsp", type = "dispatcher")}
)
public String list() {
purchasePlandetails = purchasePlanService.list(purchasePlan);
return "success";
}
/*
*//**
* 回到我的申请页面
* @return
*//*
@Action(value = "/purchaseplan",
results = { @Result(name = "success", location = "/approve/list.jsp", type = "dispatcher")}
)
public String save() {
System.out.println(purchasePlan.getApplication()+"****");
purchasePlanService.savePurchasePlan(purchasePlan);
return "success";
}
*/
/**
* 编辑采购申请 当已经开始审批的时候则不能修改
*
* @return
*/
@Action(value = "/approve/editpurchaseplanapp",
results = {
@Result(name = "success", location = "/approve/editpurchaseplanapp.jsp", type = "dispatcher"),
@Result(name = "save", location = "/tools/common/ajaxresult.jsp", type = "dispatcher")
}
)
public String editPurchasePlanApp() {
if (formAction != null && formAction.equals("save")) {
ajaxResult = new AjaxResult();
try {
if(purchasePlanList!=null && materialList!=null){
PurchasePlanDetails detail = null;
Material material = null;
for(int i=0;i<purchasePlanList.size();i++){
detail = purchasePlanList.get(i);
material = materialList.get(i);
//System.out.println("--------");
//System.out.println(detail.getId());
//System.out.println(material.getId());
detail.copyFromMaterial(material);
}
purchasePlan.setPurchasePlanDetails(purchasePlanList);
}
purchasePlanAppService.updatePurchasePlanApp(application, purchasePlan, getLoginUser());
ajaxResult.setNavTabId("main");
ajaxResult.setCallbackType(AjaxResult.CALLBACKTYPE_CLOSE);
} catch (GiroException e) {
ajaxResult.setStatusCode(AjaxResult.CODE_ERROR);
ajaxResult.setMessage(e.getMessage());
} catch (Exception e) {
e.printStackTrace();
ajaxResult.setStatusCode(AjaxResult.CODE_ERROR);
ajaxResult.setMessage("数据保存失败");
}
return "save";
} else {
user = this.getLoginUser();
department = user.getDepartment();
System.out.println(user.getRealName()+"@@@@@@@@@");
System.out.println(department.getDepName()+"@@@@@@@@@@");
if (application != null && application.getId()!= null) {
application = approveService.findById(application.getId());
purchasePlan = purchasePlanService.findById(application.getApplyNo());
//System.out.println(application.getApplyNo());
// photoHttpUrl =
// sysService.findParamValue(Param.PARAM_PHOTO_HTTP_URL);
}
return "success";
}
}
/**
* 编辑采购申请 当已经开始审批的时候则不能修改
*
* @return
*/
@Action(value = "/approve/approvepurchaseplanapp",
results = {
@Result(name = "success", location = "/approve/approvepurchaseplanapp.jsp", type = "dispatcher"),
@Result(name = "save", location = "/tools/common/ajaxresult.jsp", type = "dispatcher")
}
)
public String approvePurchasePlanApp() {
if(formAction != null && formAction.equals("save")) {
ajaxResult = new AjaxResult();
try {
approveService.approve(application, approveFlow ,getLoginUser());
ajaxResult.setNavTabId("main");
// ajaxResult.setRel("approveRel");
ajaxResult.setCallbackType(AjaxResult.CALLBACKTYPE_CLOSE);
// ajaxResult.setForwardUrl("/bolan/user/list.action?pageNum="+this.getPageNum()+"&numPerPage="+this.getNumPerPage());
}
catch (GiroException e) {
ajaxResult.setStatusCode(AjaxResult.CODE_ERROR);
ajaxResult.setMessage(e.getMessage());
}
catch (Exception e) {
e.printStackTrace();
ajaxResult.setStatusCode(AjaxResult.CODE_ERROR);
ajaxResult.setMessage("数据保存失败");
}
return "save";
} else if (formAction != null && formAction.equals("end")) {
ajaxResult = new AjaxResult();
try {
approveService
.approve(application, approveFlow, getLoginUser(),true);
ajaxResult.setNavTabId("main");
// ajaxResult.setRel("approveRel");
ajaxResult.setCallbackType(AjaxResult.CALLBACKTYPE_CLOSE);
// ajaxResult.setForwardUrl("/bolan/user/list.action?pageNum="+this.getPageNum()+"&numPerPage="+this.getNumPerPage());
} catch (GiroException e) {
ajaxResult.setStatusCode(AjaxResult.CODE_ERROR);
ajaxResult.setMessage(e.getMessage());
} catch (Exception e) {
e.printStackTrace();
ajaxResult.setStatusCode(AjaxResult.CODE_ERROR);
ajaxResult.setMessage("数据保存失败");
}
return "save";
}else {
if(application != null && application.getId() != null) {
application = approveService.findById(application.getId());
buttonFlag = approveService.showButton(application.getId());
purchasePlan = purchasePlanService.findById(application.getApplyNo());
purchasePlandetails= purchasePlanDao.list(purchasePlan);
}
return "success";
}
}
/**
* 编辑采购申请 当已经开始审批的时候则不能修改
*
* @return
*/
@Action(value = "/approve/viewpurchaseplanapp",
results = {
@Result(name = "success", location = "/approve/viewpurchaseplanapp.jsp", type = "dispatcher")
}
)
public String viewPurchaseplanApp() {
if (application != null && application.getId() != null) {
application = approveService.findById(application.getId());
purchasePlan = purchasePlanService.findById(application.getApplyNo());
purchasePlandetails= purchasePlanDao.list(purchasePlan);
}
return "success";
}
}
| [
"[email protected]"
]
| |
e54e8eb33bcf0c398677827f428b209cad84c1e8 | 2c6162e7da2b1933df479504bb1cafa12f830b28 | /BackEnd/com/someSite/service/implementation/SkillValueServiceImpl.java | 8a66f2dad28b3f6c426ee460922cead3fedffb36 | []
| no_license | SIMosiagin/Try2Beck | 4cbdae05bcf646e6adbe2baab984af5f2bed4509 | d3ea1ad579b83ceadb2f854c05f202e3a06ac765 | refs/heads/master | 2022-01-09T18:48:58.071303 | 2018-08-20T18:19:38 | 2018-08-20T18:19:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,329 | java | package com.someSite.service.implementation;
import com.someSite.dao.interfaces.SkillValueIntDao;
import com.someSite.entity.firstApplication.ColumnList;
import com.someSite.entity.thirdApplication.Employee;
import com.someSite.entity.thirdApplication.EmployeeSkills;
import com.someSite.entity.thirdApplication.SkillDescription;
import com.someSite.service.interfaces.ColumnListService;
import com.someSite.service.interfaces.EmployeeServise;
import com.someSite.service.interfaces.EmployeeSkillsService;
import com.someSite.service.interfaces.SkillValueService;
import com.someSite.entity.thirdApplication.SkillValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Service("SkillValueService")
@Transactional
public class SkillValueServiceImpl implements SkillValueService {
@Autowired
private SkillValueIntDao skillValueIntDao;
@Autowired
private EmployeeServise employeeServise;
@Autowired
private EmployeeSkillsService employeeSkillsService;
@Autowired
private SkillValueService skillValueService;
@Autowired
private ColumnListService columnListService;
public void save(SkillValue obj) {
skillValueIntDao.save(obj);
}
public List<SkillValue> findAll() {
return skillValueIntDao.findAll();
}
// public ArrayList<Employee> findByFieldString(String field, String value) {
// return employeeDao.;
// }
public SkillValue findById(int id) {
return skillValueIntDao.findById(id);
}
public void deleteById(int id) {
skillValueIntDao.deleteById(id);
}
// public void update(SkillValue newObj, SkillValue oldObj) {
// skillValueIntDao.update(newObj, oldObj);
// }
public void saveOrUpdate (SkillValue object){
skillValueIntDao.saveOrUpdate(object);
}
public void uploadToIDB(List<Map<String, Object>> dataFromTransitTable){
List<ColumnList> mappingWithExcel = columnListService.findAll();
for (Map<String, Object> m: dataFromTransitTable) {
Employee employee = null;
Object[] arrayOfMap = m.keySet().toArray();
for (int i = 3; i <arrayOfMap.length; i++){
if (i == 3){
employee = new Employee();
employee.parseString(m.get(arrayOfMap[3]).toString());
Employee dBEmployee = employeeServise.findByFirstLastName(employee.getFirstName(),employee.getLastName());
if (dBEmployee == null) employeeServise.saveOrUpdate(employee);
else employee = dBEmployee;
}
else {
EmployeeSkills employeeSkills = new EmployeeSkills();
employeeSkills.setEmployee(employee);
employeeSkills.setSkillDescription(getSkillDescriptionByList(mappingWithExcel, arrayOfMap[i].toString()));
employeeSkills.setSkillValue(skillValueService.findById((int) Double.parseDouble(m.get(arrayOfMap[i]).toString())));
EmployeeSkills dBEmployeeSkills = employeeSkillsService.findByEmployeeAndSkill(employeeSkills.getEmployee(), employeeSkills.getSkillDescription());
if (dBEmployeeSkills == null) employeeSkillsService.save(employeeSkills);
else {
dBEmployeeSkills.setSkillValue(employeeSkills.getSkillValue());
employeeSkillsService.saveOrUpdate(dBEmployeeSkills);
}
}
}
}
}
private SkillDescription getSkillDescriptionByList(List<ColumnList> mappingWithExcel, String skillDiscName){
SkillDescription skillDescription = null;
for (ColumnList mWE:mappingWithExcel) {
try {
if(mWE.getName().replaceAll(String.valueOf('"'),"").equalsIgnoreCase(skillDiscName)){
skillDescription = mWE.getSkillDescription();
break;
}
}
catch (Exception ex){
System.out.println(ex);
}
}
return skillDescription;
}
}
| [
"[email protected]"
]
| |
e4aeb893996ee90e06e22a45b4a2f79d832fef43 | 383f88c9e837faed64804de271b46a35f21e7b3e | /src/com/test/Test2.java | 35fd246db20b4c859f9e519039d8fc6717e687da | []
| no_license | mrhu0126/sunjob-hu | 70ccff72b5a7eadf6f90ccc107a40eee69fc904b | 6194334637e3e438a80a0a3fd2351077d05e910a | refs/heads/master | 2023-02-23T22:34:25.184379 | 2021-01-28T03:16:26 | 2021-01-28T03:16:26 | 333,624,363 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 134 | java | package com.test;
public class Test2 {
public static void main(String[] args) {
System.out.println("来了2");
}
}
| [
"[email protected]"
]
| |
2495ac1ca0233fdd4533f7725e14f87e6e11eb1b | c016204e23f786cf4f8c081d4d7c6e85321d7550 | /app/src/main/java/com/MJ/Hack/Sehat/UserDB.java | 4367388b4c28383b49f2f2f7fe1fd76d011cc10b | []
| no_license | NicheApp/Sehat-App | 9b8daf48a3ba87c797dee11c39d54165ec5e9a57 | 4092d8c943562e12bdc4fbaa5a60565cef025946 | refs/heads/master | 2023-02-20T02:05:58.820218 | 2021-01-07T20:24:00 | 2021-01-07T20:24:00 | 315,455,719 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 6,877 | java | package com.MJ.Hack.Sehat;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
* Created by Yo7A on 4/17/2017.
*/
class user {
private String username;
private String name;
private String password;
private String email;
private int age;
private int height;
private int weight;
private int gender;
public String getUsername() {
return username;
}
public String getemail() {
return email;
}
public String getname() {
return name;
}
public String getPass() {
return password;
}
public int getage() {
return age;
}
public int getheight() {
return height;
}
public int getweight() {
return weight;
}
public int getgender() {
return gender;
}
public void setUsername(String usrname) {
username = usrname;
}
public void setemail(String E) {
email = E;
}
public void setname(String nam) {
name = nam;
}
public void setPass(String pass) {
password = pass;
}
public void setage(int g) {
age = g;
}
public void setheight(int h) {
height = h;
}
public void setweight(int w) {
weight = w;
}
public void setgender(int gen) {
gender = gen;
}
}
public class UserDB extends SQLiteOpenHelper {
private static final int DATABASE_VERSION = 1;
private static final String DATABASE_NAME = "userDB.db";
//columns of the user Info table
private static final String TABLE = "users";
private static final String USERNAME = "username";
private static final String NAME = "name";
private static final String PASSWORD = "password";
private static final String AGE = "age";
private static final String HEIGHT = "height";
private static final String WEIGHT = "weight";
private static final String GENDER = "gender";
private static final String EMAIL = "email";
SQLiteDatabase db;
public UserDB(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
//checks if the password is correct
public String checkPass(String user) {
db = this.getReadableDatabase();
String query = "select username, password from users";
Cursor cursor = db.rawQuery(query, null);
String a, b;
b = "Not found";
if (cursor.moveToFirst()) {
do {
a = cursor.getString(0);
if (a.equals(user)) {
b = cursor.getString(1);
break;
}
} while (cursor.moveToNext());
}
cursor.close();
return b;
}
//checks if the username exist if yes it will return 0 otherwise it will return 1
public int checkUser(String user) {
db = this.getReadableDatabase();
String query = "select username from users";
Cursor cursor = db.rawQuery(query, null);
String a;
int x = 1;
if (cursor.moveToFirst()) {
do {
a = cursor.getString(0);
if (a.equals(user)) {
x = 0;
break;
}
} while (cursor.moveToNext());
}
cursor.close();
return x;
}
public String getweight(String user) {
db = this.getReadableDatabase();
String query = "select username, weight from users";
Cursor cursor = db.rawQuery(query, null);
String a, w;
w = "80";
if (cursor.moveToFirst()) {
do {
a = cursor.getString(0);
if (a.equals(user)) {
w = cursor.getString(1);
break;
}
} while (cursor.moveToNext());
}
cursor.close();
return w;
}
public String getheight(String user) {
db = this.getReadableDatabase();
String query = "select username, height from users";
Cursor cursor = db.rawQuery(query, null);
String a, h;
h = "180";
if (cursor.moveToFirst()) {
do {
a = cursor.getString(0);
if (a.equals(user)) {
h = cursor.getString(1);
break;
}
} while (cursor.moveToNext());
}
cursor.close();
return h;
}
public String getage(String user) {
db = this.getReadableDatabase();
String query = "select username, age from users";
Cursor cursor = db.rawQuery(query, null);
String a, ag;
ag = "26";
if (cursor.moveToFirst()) {
do {
a = cursor.getString(0);
if (a.equals(user)) {
ag = cursor.getString(1);
break;
}
} while (cursor.moveToNext());
}
cursor.close();
return ag;
}
public String getgender(String user) {
db = this.getReadableDatabase();
String query = "select username, gender from users";
Cursor cursor = db.rawQuery(query, null);
String a, g;
g = "2";
if (cursor.moveToFirst()) {
do {
a = cursor.getString(0);
if (a.equals(user)) {
g = cursor.getString(1);
break;
}
} while (cursor.moveToNext());
}
cursor.close();
return g;
}
public void addUser(user u) {
db = this.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(USERNAME, u.getUsername());
values.put(NAME, u.getname());
values.put(PASSWORD, u.getPass());
values.put(AGE, u.getage());
values.put(HEIGHT, u.getheight());
values.put(EMAIL, u.getemail());
values.put(WEIGHT, u.getweight());
values.put(GENDER, u.getgender());
db.insert(TABLE, null, values);
db.close();
}
@Override
public void onCreate(SQLiteDatabase db) {
String createTable = "create table users ( username text primary key not null, " +
" name text not null, password text not null, email text not null, age INTEGER not null, height INTEGER not null, weight INTEGER not null, gender INTEGER not null);";
db.execSQL(createTable);
this.db = db;
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
String query = "DROP TABLE IF EXISTS users";
db.execSQL(query);
this.db = db;
}
}
| [
"[email protected]"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.