content
stringlengths 15
442k
| obf_code
stringlengths 15
442k
| probability
float64 0
1
| obf_dict
stringlengths 0
13.5k
| lang
stringclasses 3
values | classification
stringclasses 5
values | confiability
stringlengths 1
10
|
---|---|---|---|---|---|---|
package rmkj.lib.read.global;
public class PRMWebHtmlParam {
public int width;
public int height;
public int margin;
public boolean isVertical;
/**
* 从章节最后一页开始显示
*/
public boolean loadFromEnd;
public static int END_PAGE = -1;
/**
* 从章节内指定百分比显示
*/
public boolean loadFromPercent;
public float loadPercent;
/**
* 从章节指定页码显示
*/
public boolean loadFromPage;
public int loadPage;
/**
* 从章节内指定锚点显示
*/
public boolean loadFromAnchor;
public String loadAnchor;
/**
* 从章节总页数 和页数
*/
public boolean loadFormPageAndTotalPage;
public int loadTotalPage;
/**
* 搜索模式
*/
public boolean isSearchMode;
public String searchKey;
public void resetLoad() {
loadFromEnd = false;
loadFromPage = false;
loadFromPercent = false;
loadFromAnchor = false;
loadFormPageAndTotalPage = false;
loadPage = 0;
loadTotalPage = 0;
loadAnchor = null;
isSearchMode = false;
searchKey = null;
loadPercent = Float.NaN;
}
public void resetAll() {
resetLoad();
isSearchMode = false;
searchKey = null;
}
}
| package IMPORT_0.lib.read.IMPORT_1;
public class PRMWebHtmlParam {
public int width;
public int VAR_0;
public int margin;
public boolean VAR_1;
/**
* 从章节最后一页开始显示
*/
public boolean VAR_2;
public static int END_PAGE = -1;
/**
* 从章节内指定百分比显示
*/
public boolean loadFromPercent;
public float VAR_3;
/**
* 从章节指定页码显示
*/
public boolean loadFromPage;
public int loadPage;
/**
* 从章节内指定锚点显示
*/
public boolean VAR_4;
public CLASS_0 loadAnchor;
/**
* 从章节总页数 和页数
*/
public boolean loadFormPageAndTotalPage;
public int VAR_5;
/**
* 搜索模式
*/
public boolean isSearchMode;
public CLASS_0 searchKey;
public void resetLoad() {
VAR_2 = false;
loadFromPage = false;
loadFromPercent = false;
VAR_4 = false;
loadFormPageAndTotalPage = false;
loadPage = 0;
VAR_5 = 0;
loadAnchor = null;
isSearchMode = false;
searchKey = null;
VAR_3 = Float.NaN;
}
public void resetAll() {
resetLoad();
isSearchMode = false;
searchKey = null;
}
}
| 0.318601 | {'IMPORT_0': 'rmkj', 'IMPORT_1': 'global', 'VAR_0': 'height', 'VAR_1': 'isVertical', 'VAR_2': 'loadFromEnd', 'VAR_3': 'loadPercent', 'VAR_4': 'loadFromAnchor', 'CLASS_0': 'String', 'VAR_5': 'loadTotalPage'} | java | OOP | 100.00% |
/**
* Method for handling deserialization of String objects.
* @author Tristan Bepler
*/
private static String readSpecialCaseObjectIsString(Class<?> clazz, Element cur){
if(clazz == String.class){
return cur.getTextContent();
}
return null;
} | /**
* Method for handling deserialization of String objects.
* @author Tristan Bepler
*/
private static String readSpecialCaseObjectIsString(CLASS_0<?> VAR_0, CLASS_1 VAR_1){
if(VAR_0 == String.class){
return VAR_1.getTextContent();
}
return null;
} | 0.450152 | {'CLASS_0': 'Class', 'VAR_0': 'clazz', 'CLASS_1': 'Element', 'VAR_1': 'cur'} | java | Procedural | 70.27% |
package pt.lsts.imc4j.msg;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.lang.Exception;
import java.lang.IllegalArgumentException;
import java.lang.String;
import java.nio.ByteBuffer;
import java.util.EnumSet;
import pt.lsts.imc4j.annotations.FieldType;
import pt.lsts.imc4j.annotations.IMCField;
import pt.lsts.imc4j.def.SpeedUnits;
import pt.lsts.imc4j.def.ZUnits;
import pt.lsts.imc4j.util.SerializationUtils;
import pt.lsts.imc4j.util.TupleList;
/**
* The Station Keeping Extended maneuver makes the vehicle come to the surface
* and then enter a given circular perimeter around a waypoint coordinate
* for a certain amount of time. It extends the Station Keeping maneuver with the feature
* 'Keep Safe', which allows for the vehicle to hold position underwater and popup periodically
* to communicate.
*/
public class StationKeepingExtended extends Maneuver {
public static final int ID_STATIC = 496;
/**
* WGS-84 Latitude.
*/
@FieldType(
type = IMCField.TYPE_FP64,
max = 1.5707963267948966,
min = -1.5707963267948966,
units = "rad"
)
public double lat = 0;
/**
* WGS-84 Longitude.
*/
@FieldType(
type = IMCField.TYPE_FP64,
max = 3.141592653589793,
min = -3.141592653589793,
units = "rad"
)
public double lon = 0;
/**
* Maneuver reference in the z axis. Use z_units to specify
* whether z represents depth, altitude or other.
*/
@FieldType(
type = IMCField.TYPE_FP32,
units = "m"
)
public float z = 0f;
/**
* Units of the z reference.
*/
@FieldType(
type = IMCField.TYPE_UINT8,
units = "Enumerated"
)
public ZUnits z_units = ZUnits.values()[0];
/**
* Radius.
*/
@FieldType(
type = IMCField.TYPE_FP32,
units = "m"
)
public float radius = 0f;
/**
* Duration (0 for unlimited).
*/
@FieldType(
type = IMCField.TYPE_UINT16,
units = "s"
)
public int duration = 0;
/**
* The value of the desired speed, in the scale specified
* by the "Speed Units" field.
*/
@FieldType(
type = IMCField.TYPE_FP32
)
public float speed = 0f;
/**
* Indicates the units used for the speed value.
*/
@FieldType(
type = IMCField.TYPE_UINT8,
units = "Enumerated"
)
public SpeedUnits speed_units = SpeedUnits.values()[0];
/**
* The period at which the vehicle will popup to report its position.
* Only used if flag KEEP_SAFE is on.
*/
@FieldType(
type = IMCField.TYPE_UINT16,
units = "s"
)
public int popup_period = 0;
/**
* The duration of the station keeping at surface level when it pops up.
* Only used if flag KEEP_SAFE is on.
*/
@FieldType(
type = IMCField.TYPE_UINT16,
units = "s"
)
public int popup_duration = 0;
/**
* Flags of the maneuver.
*/
@FieldType(
type = IMCField.TYPE_UINT8,
units = "Bitfield"
)
public EnumSet<FLAGS> flags = EnumSet.noneOf(FLAGS.class);
/**
* Custom settings for maneuver.
*/
@FieldType(
type = IMCField.TYPE_PLAINTEXT,
units = "TupleList"
)
public TupleList custom = new TupleList("");
public String abbrev() {
return "StationKeepingExtended";
}
public int mgid() {
return 496;
}
public byte[] serializeFields() {
try {
ByteArrayOutputStream _data = new ByteArrayOutputStream();
DataOutputStream _out = new DataOutputStream(_data);
_out.writeDouble(lat);
_out.writeDouble(lon);
_out.writeFloat(z);
_out.writeByte((int)(z_units != null? z_units.value() : 0));
_out.writeFloat(radius);
_out.writeShort(duration);
_out.writeFloat(speed);
_out.writeByte((int)(speed_units != null? speed_units.value() : 0));
_out.writeShort(popup_period);
_out.writeShort(popup_duration);
long _flags = 0;
if (flags != null) {
for (FLAGS __flags : flags.toArray(new FLAGS[0])) {
_flags += __flags.value();
}
}
_out.writeByte((int)_flags);
SerializationUtils.serializePlaintext(_out, custom == null? null : custom.toString());
return _data.toByteArray();
}
catch (IOException e) {
e.printStackTrace();
return new byte[0];
}
}
public void deserializeFields(ByteBuffer buf) throws IOException {
try {
lat = buf.getDouble();
lon = buf.getDouble();
z = buf.getFloat();
z_units = ZUnits.valueOf(buf.get() & 0xFF);
radius = buf.getFloat();
duration = buf.getShort() & 0xFFFF;
speed = buf.getFloat();
speed_units = SpeedUnits.valueOf(buf.get() & 0xFF);
popup_period = buf.getShort() & 0xFFFF;
popup_duration = buf.getShort() & 0xFFFF;
long flags_val = buf.get() & 0xFF;
flags.clear();
for (FLAGS FLAGS_op : FLAGS.values()) {
if ((flags_val & FLAGS_op.value()) == FLAGS_op.value()) {
flags.add(FLAGS_op);
}
}
custom = new TupleList(SerializationUtils.deserializePlaintext(buf));
}
catch (Exception e) {
throw new IOException(e);
}
}
public enum FLAGS {
FLG_KEEP_SAFE(0x01l);
protected long value;
FLAGS(long value) {
this.value = value;
}
long value() {
return value;
}
public static FLAGS valueOf(long value) throws IllegalArgumentException {
for (FLAGS v : FLAGS.values()) {
if (v.value == value) {
return v;
}
}
throw new IllegalArgumentException("Invalid value for FLAGS: "+value);
}
}
}
| package pt.lsts.imc4j.IMPORT_0;
import java.io.IMPORT_1;
import java.io.DataOutputStream;
import java.io.IOException;
import java.IMPORT_2.Exception;
import java.IMPORT_2.IllegalArgumentException;
import java.IMPORT_2.String;
import java.IMPORT_3.ByteBuffer;
import java.util.IMPORT_4;
import pt.lsts.imc4j.annotations.IMPORT_5;
import pt.lsts.imc4j.annotations.IMCField;
import pt.lsts.imc4j.def.SpeedUnits;
import pt.lsts.imc4j.def.IMPORT_6;
import pt.lsts.imc4j.util.SerializationUtils;
import pt.lsts.imc4j.util.TupleList;
/**
* The Station Keeping Extended maneuver makes the vehicle come to the surface
* and then enter a given circular perimeter around a waypoint coordinate
* for a certain amount of time. It extends the Station Keeping maneuver with the feature
* 'Keep Safe', which allows for the vehicle to hold position underwater and popup periodically
* to communicate.
*/
public class StationKeepingExtended extends Maneuver {
public static final int VAR_0 = 496;
/**
* WGS-84 Latitude.
*/
@IMPORT_5(
VAR_1 = IMCField.TYPE_FP64,
max = 1.5707963267948966,
VAR_2 = -1.5707963267948966,
units = "rad"
)
public double lat = 0;
/**
* WGS-84 Longitude.
*/
@IMPORT_5(
VAR_1 = IMCField.TYPE_FP64,
max = 3.141592653589793,
VAR_2 = -3.141592653589793,
units = "rad"
)
public double VAR_3 = 0;
/**
* Maneuver reference in the z axis. Use z_units to specify
* whether z represents depth, altitude or other.
*/
@IMPORT_5(
VAR_1 = IMCField.TYPE_FP32,
units = "m"
)
public float z = 0f;
/**
* Units of the z reference.
*/
@IMPORT_5(
VAR_1 = IMCField.TYPE_UINT8,
units = "Enumerated"
)
public IMPORT_6 VAR_4 = IMPORT_6.values()[0];
/**
* Radius.
*/
@IMPORT_5(
VAR_1 = IMCField.TYPE_FP32,
units = "m"
)
public float VAR_5 = 0f;
/**
* Duration (0 for unlimited).
*/
@IMPORT_5(
VAR_1 = IMCField.VAR_6,
units = "s"
)
public int VAR_7 = 0;
/**
* The value of the desired speed, in the scale specified
* by the "Speed Units" field.
*/
@IMPORT_5(
VAR_1 = IMCField.TYPE_FP32
)
public float speed = 0f;
/**
* Indicates the units used for the speed value.
*/
@IMPORT_5(
VAR_1 = IMCField.TYPE_UINT8,
units = "Enumerated"
)
public SpeedUnits speed_units = SpeedUnits.values()[0];
/**
* The period at which the vehicle will popup to report its position.
* Only used if flag KEEP_SAFE is on.
*/
@IMPORT_5(
VAR_1 = IMCField.VAR_6,
units = "s"
)
public int VAR_8 = 0;
/**
* The duration of the station keeping at surface level when it pops up.
* Only used if flag KEEP_SAFE is on.
*/
@IMPORT_5(
VAR_1 = IMCField.VAR_6,
units = "s"
)
public int popup_duration = 0;
/**
* Flags of the maneuver.
*/
@IMPORT_5(
VAR_1 = IMCField.TYPE_UINT8,
units = "Bitfield"
)
public IMPORT_4<CLASS_0> flags = IMPORT_4.FUNC_0(CLASS_0.class);
/**
* Custom settings for maneuver.
*/
@IMPORT_5(
VAR_1 = IMCField.VAR_10,
units = "TupleList"
)
public TupleList VAR_11 = new TupleList("");
public String abbrev() {
return "StationKeepingExtended";
}
public int mgid() {
return 496;
}
public byte[] serializeFields() {
try {
IMPORT_1 VAR_12 = new IMPORT_1();
DataOutputStream _out = new DataOutputStream(VAR_12);
_out.writeDouble(lat);
_out.writeDouble(VAR_3);
_out.FUNC_1(z);
_out.FUNC_2((int)(VAR_4 != null? VAR_4.FUNC_3() : 0));
_out.FUNC_1(VAR_5);
_out.writeShort(VAR_7);
_out.FUNC_1(speed);
_out.FUNC_2((int)(speed_units != null? speed_units.FUNC_3() : 0));
_out.writeShort(VAR_8);
_out.writeShort(popup_duration);
long VAR_14 = 0;
if (flags != null) {
for (CLASS_0 __flags : flags.FUNC_4(new CLASS_0[0])) {
VAR_14 += __flags.FUNC_3();
}
}
_out.FUNC_2((int)VAR_14);
SerializationUtils.serializePlaintext(_out, VAR_11 == null? null : VAR_11.FUNC_5());
return VAR_12.FUNC_6();
}
catch (IOException VAR_15) {
VAR_15.FUNC_7();
return new byte[0];
}
}
public void deserializeFields(ByteBuffer VAR_16) throws IOException {
try {
lat = VAR_16.getDouble();
VAR_3 = VAR_16.getDouble();
z = VAR_16.getFloat();
VAR_4 = IMPORT_6.FUNC_8(VAR_16.FUNC_9() & 0xFF);
VAR_5 = VAR_16.getFloat();
VAR_7 = VAR_16.getShort() & 0xFFFF;
speed = VAR_16.getFloat();
speed_units = SpeedUnits.FUNC_8(VAR_16.FUNC_9() & 0xFF);
VAR_8 = VAR_16.getShort() & 0xFFFF;
popup_duration = VAR_16.getShort() & 0xFFFF;
long flags_val = VAR_16.FUNC_9() & 0xFF;
flags.FUNC_10();
for (CLASS_0 VAR_17 : VAR_9.values()) {
if ((flags_val & VAR_17.FUNC_3()) == VAR_17.FUNC_3()) {
flags.add(VAR_17);
}
}
VAR_11 = new TupleList(SerializationUtils.FUNC_11(VAR_16));
}
catch (Exception VAR_15) {
throw new IOException(VAR_15);
}
}
public enum CLASS_0 {
FLG_KEEP_SAFE(0x01l);
protected long VAR_13;
CLASS_0(long VAR_13) {
this.VAR_13 = VAR_13;
}
long FUNC_3() {
return VAR_13;
}
public static CLASS_0 FUNC_8(long VAR_13) throws IllegalArgumentException {
for (CLASS_0 VAR_18 : VAR_9.values()) {
if (VAR_18.VAR_13 == VAR_13) {
return VAR_18;
}
}
throw new IllegalArgumentException("Invalid value for FLAGS: "+VAR_13);
}
}
}
| 0.46538 | {'IMPORT_0': 'msg', 'IMPORT_1': 'ByteArrayOutputStream', 'IMPORT_2': 'lang', 'IMPORT_3': 'nio', 'IMPORT_4': 'EnumSet', 'IMPORT_5': 'FieldType', 'IMPORT_6': 'ZUnits', 'VAR_0': 'ID_STATIC', 'VAR_1': 'type', 'VAR_2': 'min', 'VAR_3': 'lon', 'VAR_4': 'z_units', 'VAR_5': 'radius', 'VAR_6': 'TYPE_UINT16', 'VAR_7': 'duration', 'VAR_8': 'popup_period', 'CLASS_0': 'FLAGS', 'VAR_9': 'FLAGS', 'FUNC_0': 'noneOf', 'VAR_10': 'TYPE_PLAINTEXT', 'VAR_11': 'custom', 'VAR_12': '_data', 'FUNC_1': 'writeFloat', 'FUNC_2': 'writeByte', 'FUNC_3': 'value', 'VAR_13': 'value', 'VAR_14': '_flags', 'FUNC_4': 'toArray', 'FUNC_5': 'toString', 'FUNC_6': 'toByteArray', 'VAR_15': 'e', 'FUNC_7': 'printStackTrace', 'VAR_16': 'buf', 'FUNC_8': 'valueOf', 'FUNC_9': 'get', 'FUNC_10': 'clear', 'VAR_17': 'FLAGS_op', 'FUNC_11': 'deserializePlaintext', 'VAR_18': 'v'} | java | OOP | 47.21% |
package com.example.dao;
import com.example.domin.Friends;
import com.example.domin.Group;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface IFriendsDao {
/**
* 向group表添加数据
* @param account
* @param groupName
* @return
*/
@Insert("insert into `group`(`account`, `groupName`) values (#{account}, #{groupName})")
boolean groupAdd(String account, String groupName);
/**
* 查询好友分组
* @param account
* @return
*/
@Select("select groupId,groupName from `group` where account = #{account}")
List<Group> groupSelect(String account);
/**
* 根据account查询好友列表
* @param account
* @return
*/
@Select("select account,name,path from user,friends where friends.u_account = #{account} and friends.f_account = user.account and friends.groupId = #{groupId}")
List<Friends> friendSelectByGroup(String account, Integer groupId);
}
| package IMPORT_0.IMPORT_1.dao;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_4;
import IMPORT_5.IMPORT_6.IMPORT_7.IMPORT_8.IMPORT_9;
import IMPORT_5.IMPORT_6.IMPORT_7.IMPORT_8.Select;
import IMPORT_5.IMPORT_10.IMPORT_11.IMPORT_12;
import java.IMPORT_13.IMPORT_14;
@IMPORT_12
public interface CLASS_0 {
/**
* 向group表添加数据
* @param account
* @param groupName
* @return
*/
@IMPORT_9("insert into `group`(`account`, `groupName`) values (#{account}, #{groupName})")
boolean FUNC_0(CLASS_1 VAR_0, CLASS_1 VAR_1);
/**
* 查询好友分组
* @param account
* @return
*/
@Select("select groupId,groupName from `group` where account = #{account}")
IMPORT_14<IMPORT_4> FUNC_1(CLASS_1 VAR_0);
/**
* 根据account查询好友列表
* @param account
* @return
*/
@Select("select account,name,path from user,friends where friends.u_account = #{account} and friends.f_account = user.account and friends.groupId = #{groupId}")
IMPORT_14<IMPORT_3> FUNC_2(CLASS_1 VAR_0, CLASS_2 VAR_2);
}
| 0.901465 | {'IMPORT_0': 'com', 'IMPORT_1': 'example', 'IMPORT_2': 'domin', 'IMPORT_3': 'Friends', 'IMPORT_4': 'Group', 'IMPORT_5': 'org', 'IMPORT_6': 'apache', 'IMPORT_7': 'ibatis', 'IMPORT_8': 'annotations', 'IMPORT_9': 'Insert', 'IMPORT_10': 'springframework', 'IMPORT_11': 'stereotype', 'IMPORT_12': 'Repository', 'IMPORT_13': 'util', 'IMPORT_14': 'List', 'CLASS_0': 'IFriendsDao', 'FUNC_0': 'groupAdd', 'CLASS_1': 'String', 'VAR_0': 'account', 'VAR_1': 'groupName', 'FUNC_1': 'groupSelect', 'FUNC_2': 'friendSelectByGroup', 'CLASS_2': 'Integer', 'VAR_2': 'groupId'} | java | Texto | 44.44% |
package tp.p3.entity;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import static tp.p3.logic.Game.invalidAttributeValueMsq;
import static tp.p3.logic.Game.ROWS;
import static tp.p3.logic.Game.COLUMNS;
import static tp.p3.utility.MyFileUtils.loadLine;
import tp.p3.exceptions.FileContentsException;
import tp.p3.exceptions.InvalidPositionException;
import tp.p3.logic.Game;
import tp.p3.utility.PlantFactory;
import tp.p3.utility.ZombieFactory;
public class Board {
private GameObjectList PlantList;
private GameObjectList ZomList;
public Board(){
PlantList = new GameObjectList();
ZomList = new GameObjectList();
}
public void load(BufferedReader inStream, Game gamecopy) throws IOException, FileContentsException{
GameObjectList oldPlantList = PlantList;
GameObjectList oldZomList = ZomList;
try {
PlantList = new GameObjectList();
loadObjectList(loadLine(inStream, "plantList", true), gamecopy, true);
ZomList = new GameObjectList();
loadObjectList(loadLine(inStream, "zombieList", true), gamecopy, false);
}
catch(FileContentsException ex) {
PlantList = oldPlantList;
ZomList = oldZomList;
throw ex;
}
}
private void loadObjectList(String[] objList, Game gamecopy, boolean isPlant) throws FileContentsException {
String prefix = isPlant ? "plantList" : "zombieList";
String[] data;
String objName;
if(objList != null && objList.length > 0) {
for(String strObj : objList) {
if(!strObj.contains(":")) throw new FileContentsException(invalidAttributeValueMsq + prefix);
objName = strObj.substring(0, strObj.indexOf(":"));
data = strObj.substring(strObj.indexOf(":") + 1).split(":");
GameObject obj = isPlant ? PlantFactory.getPlant(objName) : ZombieFactory.getZombie(objName);
if(obj == null || !obj.parseObjectAttributes(data)) throw new FileContentsException(invalidAttributeValueMsq + prefix);
obj.setGame(gamecopy);
try {
if(isPlant) addPlant((Plant)obj);
else addZombie((Zombie)obj);
}
catch (InvalidPositionException ex) {
throw new FileContentsException(invalidAttributeValueMsq + prefix);
}
}
}
}
public void store(BufferedWriter outChars) throws IOException {
outChars.write("\nplantList: ");
for (int i = 0; i < PlantList.getNumObjects(); i++) {
outChars.write(PlantList.getStringToWriteOnFile(i));
if(i < PlantList.getNumObjects()-1) outChars.write(", ");
}
outChars.write("\nzombieList: ");
for (int j = 0; j < ZomList.getNumObjects() ; j++) {
outChars.write(ZomList.getStringToWriteOnFile(j));
if(j < ZomList.getNumObjects()-1) outChars.write(", ");
}
}
public void addPlant(Plant plant) throws InvalidPositionException {
int x = plant.getPosX(), y = plant.getPosY();
if(y < COLUMNS - 1 && isIntoBoard(x, y)) {
if(isCellEmpty(x, y)) {
if(!PlantList.add(plant)) throw new InvalidPositionException(" Failed to add " + plant.getObjectName() + ": maximum number of objects reached");
}
else throw new InvalidPositionException(" Failed to add " + plant.getObjectName() + ": position (" + x + ", " + y + ") is already occupied");
}
else throw new InvalidPositionException(" Failed to add " + plant.getObjectName() + ": (" + x + ", " + y + ") is an invalid position");
}
public void addZombie(Zombie zombie) throws InvalidPositionException {
int x = zombie.getPosX(), y = zombie.getPosY();
if(isIntoBoard(x, y)) {
if(isCellEmpty(x, y)) {
if(!ZomList.add(zombie)) throw new InvalidPositionException(" Failed to add " +zombie.getObjectName() + ": maximum number of objects reached");
}
else throw new InvalidPositionException(" Failed to add " + zombie.getObjectName() + ": position (" + x + ", " + y + ") is already occupied");
}
else throw new InvalidPositionException(" Failed to add " + zombie.getObjectName() + ": (" + x + ", " + y + ") is an invalid position");
}
public void updateBoard() {
PlantList.updateList();
ZomList.updateList();
}
public boolean ZombiesAtEnd() {
return ZomList.ObjectsAtEnd();
}
public int getNumZombiesintoBoard() {return ZomList.getNumObjects();}
public int getNumPLantsintoBoard() {return PlantList.getNumObjects();}
public int getNumObjects() {return ZomList.getNumObjects() + PlantList.getNumObjects();}
public void attackZombie(int damage, int posX, int posY) {
ZomList.attackObject(damage, posX, posY, true);
}
public void attackPlant(int damage, int posX, int posY) {
PlantList.attackObject(damage, posX, posY, false);
}
public void attackZombieinArea(int damage, int posX, int posY) {
ZomList.attackObjectArea(damage, posX, posY);
}
public int findPlantIdx(int posX, int posY) {
return PlantList.findObjectIdx(posX, posY, false);
}
public int findZombieIdx(int posX, int posY, boolean inRow) {
return ZomList.findObjectIdx(posX, posY, inRow);
}
public boolean isCellEmpty(int posX, int posY) {
boolean empty = false;
if (PlantList.findObjectIdx(posX, posY, false) == -1) {
if (ZomList.findObjectIdx(posX, posY, false) == -1) empty = true;
}
return empty;
}
public String stringOfElementRelease(int posX, int posY) {
String type = " ";
int idx = PlantList.findObjectIdx(posX, posY, false);
if (idx != -1) type = PlantList.getStringReleaseInPos(idx);
else {
idx = ZomList.findObjectIdx(posX, posY, false);
if (idx != -1) type = ZomList.getStringReleaseInPos(idx);
}
return type;
}
public String stringOfElementDebug(int idx) {
String type = "";
int NumObjects = PlantList.getNumObjects() + ZomList.getNumObjects();
if(idx >= 0 && idx < NumObjects) {
if(idx < PlantList.getNumObjects()) type = PlantList.getStringDebugInPos(idx);
else type = ZomList.getStringDebugInPos(idx - PlantList.getNumObjects());
}
return type;
}
public boolean isIntoBoard(int posX, int posY) {
return (posX >= 0 && posX < ROWS) && (posY >= 0 && posY < COLUMNS);
}
}
| package IMPORT_0.p3.IMPORT_1;
import IMPORT_2.io.BufferedReader;
import IMPORT_2.io.BufferedWriter;
import IMPORT_2.io.IMPORT_3;
import static IMPORT_0.p3.logic.IMPORT_4.IMPORT_5;
import static IMPORT_0.p3.logic.IMPORT_4.ROWS;
import static IMPORT_0.p3.logic.IMPORT_4.COLUMNS;
import static IMPORT_0.p3.utility.IMPORT_6.loadLine;
import IMPORT_0.p3.IMPORT_7.FileContentsException;
import IMPORT_0.p3.IMPORT_7.IMPORT_8;
import IMPORT_0.p3.logic.IMPORT_4;
import IMPORT_0.p3.utility.PlantFactory;
import IMPORT_0.p3.utility.ZombieFactory;
public class Board {
private GameObjectList PlantList;
private GameObjectList VAR_0;
public Board(){
PlantList = new GameObjectList();
VAR_0 = new GameObjectList();
}
public void load(BufferedReader inStream, IMPORT_4 VAR_1) throws IMPORT_3, FileContentsException{
GameObjectList oldPlantList = PlantList;
GameObjectList oldZomList = VAR_0;
try {
PlantList = new GameObjectList();
loadObjectList(loadLine(inStream, "plantList", true), VAR_1, true);
VAR_0 = new GameObjectList();
loadObjectList(loadLine(inStream, "zombieList", true), VAR_1, false);
}
catch(FileContentsException VAR_2) {
PlantList = oldPlantList;
VAR_0 = oldZomList;
throw VAR_2;
}
}
private void loadObjectList(String[] objList, IMPORT_4 VAR_1, boolean VAR_3) throws FileContentsException {
String VAR_4 = VAR_3 ? "plantList" : "zombieList";
String[] VAR_5;
String objName;
if(objList != null && objList.VAR_6 > 0) {
for(String VAR_7 : objList) {
if(!VAR_7.FUNC_0(":")) throw new FileContentsException(IMPORT_5 + VAR_4);
objName = VAR_7.FUNC_1(0, VAR_7.FUNC_2(":"));
VAR_5 = VAR_7.FUNC_1(VAR_7.FUNC_2(":") + 1).split(":");
CLASS_0 obj = VAR_3 ? PlantFactory.FUNC_3(objName) : ZombieFactory.FUNC_4(objName);
if(obj == null || !obj.parseObjectAttributes(VAR_5)) throw new FileContentsException(IMPORT_5 + VAR_4);
obj.FUNC_5(VAR_1);
try {
if(VAR_3) FUNC_6((Plant)obj);
else FUNC_7((CLASS_1)obj);
}
catch (IMPORT_8 VAR_2) {
throw new FileContentsException(IMPORT_5 + VAR_4);
}
}
}
}
public void store(BufferedWriter VAR_8) throws IMPORT_3 {
VAR_8.write("\nplantList: ");
for (int i = 0; i < PlantList.FUNC_8(); i++) {
VAR_8.write(PlantList.FUNC_9(i));
if(i < PlantList.FUNC_8()-1) VAR_8.write(", ");
}
VAR_8.write("\nzombieList: ");
for (int VAR_9 = 0; VAR_9 < VAR_0.FUNC_8() ; VAR_9++) {
VAR_8.write(VAR_0.FUNC_9(VAR_9));
if(VAR_9 < VAR_0.FUNC_8()-1) VAR_8.write(", ");
}
}
public void FUNC_6(Plant VAR_10) throws IMPORT_8 {
int VAR_11 = VAR_10.getPosX(), y = VAR_10.FUNC_10();
if(y < COLUMNS - 1 && isIntoBoard(VAR_11, y)) {
if(isCellEmpty(VAR_11, y)) {
if(!PlantList.add(VAR_10)) throw new IMPORT_8(" Failed to add " + VAR_10.getObjectName() + ": maximum number of objects reached");
}
else throw new IMPORT_8(" Failed to add " + VAR_10.getObjectName() + ": position (" + VAR_11 + ", " + y + ") is already occupied");
}
else throw new IMPORT_8(" Failed to add " + VAR_10.getObjectName() + ": (" + VAR_11 + ", " + y + ") is an invalid position");
}
public void FUNC_7(CLASS_1 VAR_12) throws IMPORT_8 {
int VAR_11 = VAR_12.getPosX(), y = VAR_12.FUNC_10();
if(isIntoBoard(VAR_11, y)) {
if(isCellEmpty(VAR_11, y)) {
if(!VAR_0.add(VAR_12)) throw new IMPORT_8(" Failed to add " +VAR_12.getObjectName() + ": maximum number of objects reached");
}
else throw new IMPORT_8(" Failed to add " + VAR_12.getObjectName() + ": position (" + VAR_11 + ", " + y + ") is already occupied");
}
else throw new IMPORT_8(" Failed to add " + VAR_12.getObjectName() + ": (" + VAR_11 + ", " + y + ") is an invalid position");
}
public void FUNC_11() {
PlantList.updateList();
VAR_0.updateList();
}
public boolean FUNC_12() {
return VAR_0.FUNC_13();
}
public int getNumZombiesintoBoard() {return VAR_0.FUNC_8();}
public int FUNC_14() {return PlantList.FUNC_8();}
public int FUNC_8() {return VAR_0.FUNC_8() + PlantList.FUNC_8();}
public void FUNC_15(int VAR_13, int VAR_14, int posY) {
VAR_0.FUNC_16(VAR_13, VAR_14, posY, true);
}
public void attackPlant(int VAR_13, int VAR_14, int posY) {
PlantList.FUNC_16(VAR_13, VAR_14, posY, false);
}
public void FUNC_17(int VAR_13, int VAR_14, int posY) {
VAR_0.attackObjectArea(VAR_13, VAR_14, posY);
}
public int findPlantIdx(int VAR_14, int posY) {
return PlantList.FUNC_18(VAR_14, posY, false);
}
public int findZombieIdx(int VAR_14, int posY, boolean VAR_15) {
return VAR_0.FUNC_18(VAR_14, posY, VAR_15);
}
public boolean isCellEmpty(int VAR_14, int posY) {
boolean empty = false;
if (PlantList.FUNC_18(VAR_14, posY, false) == -1) {
if (VAR_0.FUNC_18(VAR_14, posY, false) == -1) empty = true;
}
return empty;
}
public String stringOfElementRelease(int VAR_14, int posY) {
String type = " ";
int idx = PlantList.FUNC_18(VAR_14, posY, false);
if (idx != -1) type = PlantList.FUNC_19(idx);
else {
idx = VAR_0.FUNC_18(VAR_14, posY, false);
if (idx != -1) type = VAR_0.FUNC_19(idx);
}
return type;
}
public String FUNC_20(int idx) {
String type = "";
int VAR_16 = PlantList.FUNC_8() + VAR_0.FUNC_8();
if(idx >= 0 && idx < VAR_16) {
if(idx < PlantList.FUNC_8()) type = PlantList.FUNC_21(idx);
else type = VAR_0.FUNC_21(idx - PlantList.FUNC_8());
}
return type;
}
public boolean isIntoBoard(int VAR_14, int posY) {
return (VAR_14 >= 0 && VAR_14 < ROWS) && (posY >= 0 && posY < COLUMNS);
}
}
| 0.459923 | {'IMPORT_0': 'tp', 'IMPORT_1': 'entity', 'IMPORT_2': 'java', 'IMPORT_3': 'IOException', 'IMPORT_4': 'Game', 'IMPORT_5': 'invalidAttributeValueMsq', 'IMPORT_6': 'MyFileUtils', 'IMPORT_7': 'exceptions', 'IMPORT_8': 'InvalidPositionException', 'VAR_0': 'ZomList', 'VAR_1': 'gamecopy', 'VAR_2': 'ex', 'VAR_3': 'isPlant', 'VAR_4': 'prefix', 'VAR_5': 'data', 'VAR_6': 'length', 'VAR_7': 'strObj', 'FUNC_0': 'contains', 'FUNC_1': 'substring', 'FUNC_2': 'indexOf', 'CLASS_0': 'GameObject', 'FUNC_3': 'getPlant', 'FUNC_4': 'getZombie', 'FUNC_5': 'setGame', 'FUNC_6': 'addPlant', 'FUNC_7': 'addZombie', 'CLASS_1': 'Zombie', 'VAR_8': 'outChars', 'FUNC_8': 'getNumObjects', 'FUNC_9': 'getStringToWriteOnFile', 'VAR_9': 'j', 'VAR_10': 'plant', 'VAR_11': 'x', 'FUNC_10': 'getPosY', 'VAR_12': 'zombie', 'FUNC_11': 'updateBoard', 'FUNC_12': 'ZombiesAtEnd', 'FUNC_13': 'ObjectsAtEnd', 'FUNC_14': 'getNumPLantsintoBoard', 'FUNC_15': 'attackZombie', 'VAR_13': 'damage', 'VAR_14': 'posX', 'FUNC_16': 'attackObject', 'FUNC_17': 'attackZombieinArea', 'FUNC_18': 'findObjectIdx', 'VAR_15': 'inRow', 'FUNC_19': 'getStringReleaseInPos', 'FUNC_20': 'stringOfElementDebug', 'VAR_16': 'NumObjects', 'FUNC_21': 'getStringDebugInPos'} | java | OOP | 13.83% |
/**
* The type Course player service.
*/
@Service
public class CoursePlayerServiceImpl implements CoursePlayerService {
/**
* The Totara enrollment service.
*/
@Inject
TotaraEnrollmentService totaraEnrollmentService;
/**
* The Totara course service.
*/
@Inject
TotaraCourseService totaraCourseService;
/**
* The Totara section service.
*/
@Inject
TotaraSectionService totaraSectionService;
/**
* The Totara activity service.
*/
@Inject
TotaraActivityService totaraActivityService;
/**
* The Video time repository.
*/
@Inject
VideoTimeRepository videoTimeRepository;
@Override
public CoursePlayerCourseDTO getCourseAndSectionsHaveAcitivitesForUser(Long courseId,
Long personTotaraId, boolean includeActivities) {
// check if user is enrolled in course
if (!totaraEnrollmentService.isUserEnrolledInCourse(courseId, personTotaraId)) {
throw new GeneralException(ErrorCodeGeneral.BAD_REQUEST,
"This user is not enrolled in this course.");
}
// get course
CoursePlayerCourseDTO course = totaraCourseService.getEnrolledCourse(personTotaraId, courseId);
// get sections for course
List<CoursePlayerSectionDTO> sections =
totaraSectionService.getGeneralSectionsHaveActivitiesForCourse(courseId);
course.setSections(sections);
// TODO: (WJK) Replace this with something more efficient
if (includeActivities) {
for (CoursePlayerSectionDTO section : sections) {
List<CoursePlayerActivityDTO> activities =
totaraActivityService.getActivitiesBySection(courseId, section.getId());
section.setActivities(activities);
section.sortActivities();
}
}
return course;
}
@Override
public CoursePlayerSectionDTO getActivitiesForSectionForCourse(Long courseId, Long sectionId,
Long personTotaraId) {
// check if user is enrolled in course
if (!totaraEnrollmentService.isUserEnrolledInCourse(courseId, personTotaraId)) {
throw new GeneralException(ErrorCodeGeneral.BAD_REQUEST,
"This user is not enrolled in this course.");
}
// get the section for the course
CoursePlayerSectionDTO section = totaraSectionService.getSectionForCourse(courseId, sectionId);
// get the activities for the section
List<CoursePlayerActivityDTO> activities =
totaraActivityService.getActivitiesBySection(courseId, sectionId);
section.setActivities(activities);
section.sortActivities();
return section;
}
@Override
public CoursePlayerActivityDTO getActivityContent(Long courseId, Long activityId, Long personId,
Long personTotaraId) {
// check if user is enrolled in course
if (!totaraEnrollmentService.isUserEnrolledInCourse(courseId, personTotaraId)) {
throw new GeneralException(ErrorCodeGeneral.BAD_REQUEST,
"This user is not enrolled in this course.");
}
return totaraActivityService.getActivityContent(activityId, personId, personTotaraId);
}
@Override
public CoursePlayerActivityDTO markActivityComplete(Long courseId, Long activityId, Long personId,
Long personTotaraId) {
return markActivityState(courseId, activityId, personId, personTotaraId, 1);
}
@Override
public CoursePlayerActivityDTO markActivityIncomplete(Long courseId, Long activityId,
Long personId, Long personTotaraId) {
return markActivityState(courseId, activityId, personId, personTotaraId, 0);
}
private CoursePlayerActivityDTO markActivityState(Long courseId, Long activityId, Long personId,
Long personTotaraId, int targetState) {
// check if user is enrolled in course
if (!totaraEnrollmentService.isUserEnrolledInCourse(courseId, personTotaraId)) {
throw new GeneralException(ErrorCodeGeneral.BAD_REQUEST,
"This user is not enrolled in this course.");
}
CoursePlayerActivityDTO bo =
totaraActivityService.getActivityContent(activityId, personId, personTotaraId);
if (bo.getIsLocked()) {
throw new GeneralException(ErrorCodeGeneral.BAD_REQUEST,
"This activity is locked and cannot be marked complete.");
}
// TODO: Verify the completion criteria here allows for direct learner completion
// if activity is URL or Resource or Certificate or Label Mark Complete.
if (bo.getType().equals(ActivityType.URL) || bo.getType().equals(ActivityType.RESOURCE)
|| bo.getType().equals(ActivityType.CERTIFICATE) || bo.getType().equals(ActivityType.LABEL)
|| bo.getType().equals(ActivityType.PAGE) || bo.getType().equals(ActivityType.SCORM)) {
totaraActivityService.completeActivity(bo.getId(), personTotaraId, targetState);
}
return bo;
}
@Override
public List<CoursePlayerActivityStatusAvailabilityDTO> getStatusForActivitiesInCourse(
Long courseId, Long personTotaraId) {
return totaraActivityService.getStatusForActivitiesInCourse(courseId, personTotaraId);
}
@Override
public List<CoursePlayerActivityStatusAvailabilityDTO> getStatusForActivitiesInSameCourse(
Long activityId, Long personTotaraId) {
return totaraActivityService.getStatusForActivitiesInSameCourse(activityId, personTotaraId);
}
@Override
public TotaraActivityCompletionDTO submitFeedbackActivity(Long courseId, Long moduleId,
Long personTotaraId, String data) {
// check if user is enrolled in course
if (!totaraEnrollmentService.isUserEnrolledInCourse(courseId, personTotaraId)) {
throw new GeneralException(ErrorCodeGeneral.BAD_REQUEST,
"This user is not enrolled in this course.");
}
return totaraActivityService.completeActivityWithData(moduleId, personTotaraId, 1, data);
}
@Override
public Map<String, Object> submitQuizQuestions(Long courseId, Long moudeId, Long personTotaraId,
CoursePlayerActivityQuizSubmitDTO dto) {
// check if user is enrolled in course
if (!totaraEnrollmentService.isUserEnrolledInCourse(courseId, personTotaraId)) {
throw new GeneralException(ErrorCodeGeneral.BAD_REQUEST,
"This user is not enrolled in this course.");
}
// send questions
String responseString =
totaraActivityService.submitTotaraActivityQuizQuestionAnswer(dto, personTotaraId);
// grade quiz
QuizScoreDTO quizScore =
totaraActivityService.submitTotaraActivityQuizAttempt(dto.getAttemptId(), personTotaraId);
// mark quiz as complete
totaraActivityService.completeActivity(moudeId, personTotaraId, 1);
Map<String, Object> responseMap = new HashMap<>();
responseMap.put("questionResponse", responseString);
responseMap.put("scoreResponse", quizScore);
return responseMap;
}
@Override
public void saveCourseCompleteVerification(Long courseId, Long personTotaraId) {
if (courseId == null) {
throw new GeneralException(ErrorCodeGeneral.BAD_REQUEST,
"Cannot find a course without an id.");
}
// write into user customize table
}
@Override
public CoursePlayerActivityChoiceDTO getChoice(Long personTotaraId, Long moduleId) {
return totaraActivityService.getChoiceContent(personTotaraId, moduleId);
}
@Override
public CoursePlayerActivityChoiceDTO submitChoice(Long moduleId, Long personTotraId,
CoursePlayerActivityChoiceDTO incomingDTO) {
return totaraActivityService.submitChoice(personTotraId, moduleId, incomingDTO);
}
@Override
@Transactional
public void saveVideoTime(Long personId, Long personTotaraId, Long courseId, Long activityId,
Double videoTime) {
// check if user is enrolled in course
if (!totaraEnrollmentService.isUserEnrolledInCourse(courseId, personTotaraId)) {
throw new GeneralException(ErrorCodeGeneral.BAD_REQUEST,
"This user is not enrolled in this course.");
}
VideoTime videoTimeObj = videoTimeRepository.findByModuleIdAndPersonId(activityId, personId);
if (videoTimeObj == null) {
videoTimeObj = new VideoTime();
videoTimeObj.setCourseId(courseId);
videoTimeObj.setModuleId(activityId);
videoTimeObj.setPersonId(personId);
videoTimeObj.setTime(videoTime);
videoTimeRepository.save(videoTimeObj);
} else {
videoTimeRepository.updateTime(activityId, personId, videoTime);
}
}
} | /**
* The type Course player service.
*/
@Service
public class CoursePlayerServiceImpl implements CLASS_0 {
/**
* The Totara enrollment service.
*/
@Inject
TotaraEnrollmentService totaraEnrollmentService;
/**
* The Totara course service.
*/
@Inject
TotaraCourseService totaraCourseService;
/**
* The Totara section service.
*/
@Inject
TotaraSectionService totaraSectionService;
/**
* The Totara activity service.
*/
@Inject
TotaraActivityService totaraActivityService;
/**
* The Video time repository.
*/
@Inject
VideoTimeRepository videoTimeRepository;
@Override
public CoursePlayerCourseDTO getCourseAndSectionsHaveAcitivitesForUser(Long VAR_0,
Long personTotaraId, boolean includeActivities) {
// check if user is enrolled in course
if (!totaraEnrollmentService.isUserEnrolledInCourse(VAR_0, personTotaraId)) {
throw new CLASS_1(ErrorCodeGeneral.BAD_REQUEST,
"This user is not enrolled in this course.");
}
// get course
CoursePlayerCourseDTO course = totaraCourseService.FUNC_0(personTotaraId, VAR_0);
// get sections for course
List<CoursePlayerSectionDTO> sections =
totaraSectionService.FUNC_1(VAR_0);
course.setSections(sections);
// TODO: (WJK) Replace this with something more efficient
if (includeActivities) {
for (CoursePlayerSectionDTO VAR_1 : sections) {
List<CoursePlayerActivityDTO> VAR_2 =
totaraActivityService.getActivitiesBySection(VAR_0, VAR_1.getId());
VAR_1.setActivities(VAR_2);
VAR_1.sortActivities();
}
}
return course;
}
@Override
public CoursePlayerSectionDTO FUNC_2(Long VAR_0, Long sectionId,
Long personTotaraId) {
// check if user is enrolled in course
if (!totaraEnrollmentService.isUserEnrolledInCourse(VAR_0, personTotaraId)) {
throw new CLASS_1(ErrorCodeGeneral.BAD_REQUEST,
"This user is not enrolled in this course.");
}
// get the section for the course
CoursePlayerSectionDTO VAR_1 = totaraSectionService.FUNC_3(VAR_0, sectionId);
// get the activities for the section
List<CoursePlayerActivityDTO> VAR_2 =
totaraActivityService.getActivitiesBySection(VAR_0, sectionId);
VAR_1.setActivities(VAR_2);
VAR_1.sortActivities();
return VAR_1;
}
@Override
public CoursePlayerActivityDTO FUNC_4(Long VAR_0, Long activityId, Long personId,
Long personTotaraId) {
// check if user is enrolled in course
if (!totaraEnrollmentService.isUserEnrolledInCourse(VAR_0, personTotaraId)) {
throw new CLASS_1(ErrorCodeGeneral.BAD_REQUEST,
"This user is not enrolled in this course.");
}
return totaraActivityService.FUNC_4(activityId, personId, personTotaraId);
}
@Override
public CoursePlayerActivityDTO FUNC_5(Long VAR_0, Long activityId, Long personId,
Long personTotaraId) {
return markActivityState(VAR_0, activityId, personId, personTotaraId, 1);
}
@Override
public CoursePlayerActivityDTO markActivityIncomplete(Long VAR_0, Long activityId,
Long personId, Long personTotaraId) {
return markActivityState(VAR_0, activityId, personId, personTotaraId, 0);
}
private CoursePlayerActivityDTO markActivityState(Long VAR_0, Long activityId, Long personId,
Long personTotaraId, int targetState) {
// check if user is enrolled in course
if (!totaraEnrollmentService.isUserEnrolledInCourse(VAR_0, personTotaraId)) {
throw new CLASS_1(ErrorCodeGeneral.BAD_REQUEST,
"This user is not enrolled in this course.");
}
CoursePlayerActivityDTO bo =
totaraActivityService.FUNC_4(activityId, personId, personTotaraId);
if (bo.getIsLocked()) {
throw new CLASS_1(ErrorCodeGeneral.BAD_REQUEST,
"This activity is locked and cannot be marked complete.");
}
// TODO: Verify the completion criteria here allows for direct learner completion
// if activity is URL or Resource or Certificate or Label Mark Complete.
if (bo.getType().equals(ActivityType.URL) || bo.getType().equals(ActivityType.VAR_3)
|| bo.getType().equals(ActivityType.CERTIFICATE) || bo.getType().equals(ActivityType.LABEL)
|| bo.getType().equals(ActivityType.PAGE) || bo.getType().equals(ActivityType.SCORM)) {
totaraActivityService.completeActivity(bo.getId(), personTotaraId, targetState);
}
return bo;
}
@Override
public List<CLASS_2> getStatusForActivitiesInCourse(
Long VAR_0, Long personTotaraId) {
return totaraActivityService.getStatusForActivitiesInCourse(VAR_0, personTotaraId);
}
@Override
public List<CLASS_2> getStatusForActivitiesInSameCourse(
Long activityId, Long personTotaraId) {
return totaraActivityService.getStatusForActivitiesInSameCourse(activityId, personTotaraId);
}
@Override
public CLASS_3 submitFeedbackActivity(Long VAR_0, Long moduleId,
Long personTotaraId, String VAR_4) {
// check if user is enrolled in course
if (!totaraEnrollmentService.isUserEnrolledInCourse(VAR_0, personTotaraId)) {
throw new CLASS_1(ErrorCodeGeneral.BAD_REQUEST,
"This user is not enrolled in this course.");
}
return totaraActivityService.completeActivityWithData(moduleId, personTotaraId, 1, VAR_4);
}
@Override
public Map<String, Object> submitQuizQuestions(Long VAR_0, Long VAR_5, Long personTotaraId,
CoursePlayerActivityQuizSubmitDTO dto) {
// check if user is enrolled in course
if (!totaraEnrollmentService.isUserEnrolledInCourse(VAR_0, personTotaraId)) {
throw new CLASS_1(ErrorCodeGeneral.BAD_REQUEST,
"This user is not enrolled in this course.");
}
// send questions
String responseString =
totaraActivityService.FUNC_6(dto, personTotaraId);
// grade quiz
QuizScoreDTO quizScore =
totaraActivityService.submitTotaraActivityQuizAttempt(dto.getAttemptId(), personTotaraId);
// mark quiz as complete
totaraActivityService.completeActivity(VAR_5, personTotaraId, 1);
Map<String, Object> responseMap = new HashMap<>();
responseMap.FUNC_7("questionResponse", responseString);
responseMap.FUNC_7("scoreResponse", quizScore);
return responseMap;
}
@Override
public void FUNC_8(Long VAR_0, Long personTotaraId) {
if (VAR_0 == null) {
throw new CLASS_1(ErrorCodeGeneral.BAD_REQUEST,
"Cannot find a course without an id.");
}
// write into user customize table
}
@Override
public CLASS_4 FUNC_9(Long personTotaraId, Long moduleId) {
return totaraActivityService.getChoiceContent(personTotaraId, moduleId);
}
@Override
public CLASS_4 submitChoice(Long moduleId, Long personTotraId,
CLASS_4 VAR_6) {
return totaraActivityService.submitChoice(personTotraId, moduleId, VAR_6);
}
@Override
@VAR_7
public void saveVideoTime(Long personId, Long personTotaraId, Long VAR_0, Long activityId,
CLASS_5 videoTime) {
// check if user is enrolled in course
if (!totaraEnrollmentService.isUserEnrolledInCourse(VAR_0, personTotaraId)) {
throw new CLASS_1(ErrorCodeGeneral.BAD_REQUEST,
"This user is not enrolled in this course.");
}
VideoTime VAR_8 = videoTimeRepository.findByModuleIdAndPersonId(activityId, personId);
if (VAR_8 == null) {
VAR_8 = new VideoTime();
VAR_8.setCourseId(VAR_0);
VAR_8.setModuleId(activityId);
VAR_8.setPersonId(personId);
VAR_8.setTime(videoTime);
videoTimeRepository.FUNC_10(VAR_8);
} else {
videoTimeRepository.FUNC_11(activityId, personId, videoTime);
}
}
} | 0.303343 | {'CLASS_0': 'CoursePlayerService', 'VAR_0': 'courseId', 'CLASS_1': 'GeneralException', 'FUNC_0': 'getEnrolledCourse', 'FUNC_1': 'getGeneralSectionsHaveActivitiesForCourse', 'VAR_1': 'section', 'VAR_2': 'activities', 'FUNC_2': 'getActivitiesForSectionForCourse', 'FUNC_3': 'getSectionForCourse', 'FUNC_4': 'getActivityContent', 'FUNC_5': 'markActivityComplete', 'VAR_3': 'RESOURCE', 'CLASS_2': 'CoursePlayerActivityStatusAvailabilityDTO', 'CLASS_3': 'TotaraActivityCompletionDTO', 'VAR_4': 'data', 'VAR_5': 'moudeId', 'FUNC_6': 'submitTotaraActivityQuizQuestionAnswer', 'FUNC_7': 'put', 'FUNC_8': 'saveCourseCompleteVerification', 'CLASS_4': 'CoursePlayerActivityChoiceDTO', 'FUNC_9': 'getChoice', 'VAR_6': 'incomingDTO', 'VAR_7': 'Transactional', 'CLASS_5': 'Double', 'VAR_8': 'videoTimeObj', 'FUNC_10': 'save', 'FUNC_11': 'updateTime'} | java | OOP | 8.43% |
package gov.nih.nci.evs.testUtil.ui;
import gov.nih.nci.evs.testUtil.*;
import gov.nih.nci.evs.browser.utils.*;
import gov.nih.nci.evs.browser.bean.*;
import java.io.*;
import java.util.*;
import java.net.*;
public class NCImUITestGeneratorRunner {
private static String PACKAGE_NAME = "package_name";
private static String CLASS_NAME = "class_name";
private static String REMOTE_WEB_DRIVER_URL = "remoteWebDriverURL";
private static String BASE_URL = "baseUrl";
private static String SERVICE_URL = "serviceUrl";
private static String DELAY = "delay";
private Properties properties = null;
private String propertyFile = "resources/Test.properties";
private CodeGeneratorConfiguration config = null;
private NCImUITestGenerator generator = null;
public NCImUITestGeneratorRunner() {
initialize();
}
public NCImUITestGeneratorRunner(String propertyFile) {
this.propertyFile = propertyFile;
initialize();
}
public void initialize() {
properties = loadProperties();
String packageName = properties.getProperty(PACKAGE_NAME);
String className = properties.getProperty(CLASS_NAME);
String remoteWebDriverURL = properties.getProperty(REMOTE_WEB_DRIVER_URL);
String baseUrl = properties.getProperty(BASE_URL);
String serviceUrl = properties.getProperty(SERVICE_URL);
String delay_str = properties.getProperty(DELAY);
int delay = 1;
if (delay_str != null) {
delay = Integer.parseInt(delay_str);
}
config = new CodeGeneratorConfiguration();
config.setPackageName(packageName);
config.setClassName(className);
config.setRemoteWebDriverURL(remoteWebDriverURL);
config.setBaseUrl(baseUrl);
config.setServiceUrl(serviceUrl);
config.setDelay(delay);
System.out.println("packageName: " + packageName);
System.out.println("className: " + className);
System.out.println("remoteWebDriverURL: " + remoteWebDriverURL);
System.out.println("baseUrl: " + baseUrl);
System.out.println("serviceUrl: " + serviceUrl);
System.out.println("delay: " + delay);
System.out.println("Instantiate NCImUITestGenerator... ");
generator = new NCImUITestGenerator(config);
System.out.println("NCImUITestGenerator instantiated.");
}
public void run() {
generator.run();
}
private Properties loadProperties() {
try{
properties = new Properties();
if(propertyFile != null && propertyFile.length() > 0){
FileInputStream fis = new FileInputStream(new File(propertyFile));
properties.load(fis);
}
for(Iterator i = properties.keySet().iterator(); i.hasNext();){
String key = (String)i.next();
String value = properties.getProperty(key);
}
return properties;
} catch (Exception e){
System.out.println("Error reading properties file");
e.printStackTrace();
return null;
}
}
public static void main(String[] args) {
if (args.length>0) {
String propertyFile = args[0];
NCImUITestGeneratorRunner runner = new NCImUITestGeneratorRunner(propertyFile);
runner.run();
} else {
NCImUITestGeneratorRunner runner = new NCImUITestGeneratorRunner();
runner.run();
}
}
}
| package gov.nih.nci.evs.testUtil.ui;
import gov.nih.nci.evs.testUtil.*;
import gov.nih.nci.evs.browser.IMPORT_0.*;
import gov.nih.nci.evs.browser.IMPORT_1.*;
import IMPORT_2.io.*;
import IMPORT_2.IMPORT_3.*;
import IMPORT_2.IMPORT_4.*;
public class CLASS_0 {
private static String VAR_0 = "package_name";
private static String VAR_1 = "class_name";
private static String VAR_2 = "remoteWebDriverURL";
private static String VAR_3 = "baseUrl";
private static String VAR_4 = "serviceUrl";
private static String VAR_5 = "delay";
private Properties VAR_6 = null;
private String VAR_7 = "resources/Test.properties";
private CLASS_1 config = null;
private CLASS_2 generator = null;
public CLASS_0() {
initialize();
}
public CLASS_0(String VAR_7) {
this.VAR_7 = VAR_7;
initialize();
}
public void initialize() {
VAR_6 = loadProperties();
String VAR_8 = VAR_6.getProperty(VAR_0);
String VAR_9 = VAR_6.getProperty(VAR_1);
String remoteWebDriverURL = VAR_6.getProperty(VAR_2);
String VAR_10 = VAR_6.getProperty(VAR_3);
String serviceUrl = VAR_6.getProperty(VAR_4);
String VAR_11 = VAR_6.getProperty(VAR_5);
int VAR_12 = 1;
if (VAR_11 != null) {
VAR_12 = VAR_13.FUNC_0(VAR_11);
}
config = new CLASS_1();
config.setPackageName(VAR_8);
config.FUNC_1(VAR_9);
config.FUNC_2(remoteWebDriverURL);
config.FUNC_3(VAR_10);
config.FUNC_4(serviceUrl);
config.FUNC_5(VAR_12);
System.VAR_14.FUNC_6("packageName: " + VAR_8);
System.VAR_14.FUNC_6("className: " + VAR_9);
System.VAR_14.FUNC_6("remoteWebDriverURL: " + remoteWebDriverURL);
System.VAR_14.FUNC_6("baseUrl: " + VAR_10);
System.VAR_14.FUNC_6("serviceUrl: " + serviceUrl);
System.VAR_14.FUNC_6("delay: " + VAR_12);
System.VAR_14.FUNC_6("Instantiate NCImUITestGenerator... ");
generator = new CLASS_2(config);
System.VAR_14.FUNC_6("NCImUITestGenerator instantiated.");
}
public void FUNC_7() {
generator.FUNC_7();
}
private Properties loadProperties() {
try{
VAR_6 = new Properties();
if(VAR_7 != null && VAR_7.FUNC_8() > 0){
CLASS_3 VAR_16 = new CLASS_3(new File(VAR_7));
VAR_6.load(VAR_16);
}
for(CLASS_4 i = VAR_6.FUNC_9().FUNC_10(); i.FUNC_11();){
String key = (String)i.next();
String VAR_17 = VAR_6.getProperty(key);
}
return VAR_6;
} catch (Exception VAR_18){
System.VAR_14.FUNC_6("Error reading properties file");
VAR_18.FUNC_12();
return null;
}
}
public static void FUNC_13(String[] VAR_19) {
if (VAR_19.VAR_15>0) {
String VAR_7 = VAR_19[0];
CLASS_0 VAR_20 = new CLASS_0(VAR_7);
VAR_20.FUNC_7();
} else {
CLASS_0 VAR_20 = new CLASS_0();
VAR_20.FUNC_7();
}
}
}
| 0.730763 | {'IMPORT_0': 'utils', 'IMPORT_1': 'bean', 'IMPORT_2': 'java', 'IMPORT_3': 'util', 'IMPORT_4': 'net', 'CLASS_0': 'NCImUITestGeneratorRunner', 'VAR_0': 'PACKAGE_NAME', 'VAR_1': 'CLASS_NAME', 'VAR_2': 'REMOTE_WEB_DRIVER_URL', 'VAR_3': 'BASE_URL', 'VAR_4': 'SERVICE_URL', 'VAR_5': 'DELAY', 'VAR_6': 'properties', 'VAR_7': 'propertyFile', 'CLASS_1': 'CodeGeneratorConfiguration', 'CLASS_2': 'NCImUITestGenerator', 'VAR_8': 'packageName', 'VAR_9': 'className', 'VAR_10': 'baseUrl', 'VAR_11': 'delay_str', 'VAR_12': 'delay', 'VAR_13': 'Integer', 'FUNC_0': 'parseInt', 'FUNC_1': 'setClassName', 'FUNC_2': 'setRemoteWebDriverURL', 'FUNC_3': 'setBaseUrl', 'FUNC_4': 'setServiceUrl', 'FUNC_5': 'setDelay', 'VAR_14': 'out', 'FUNC_6': 'println', 'FUNC_7': 'run', 'FUNC_8': 'length', 'VAR_15': 'length', 'CLASS_3': 'FileInputStream', 'VAR_16': 'fis', 'CLASS_4': 'Iterator', 'FUNC_9': 'keySet', 'FUNC_10': 'iterator', 'FUNC_11': 'hasNext', 'VAR_17': 'value', 'VAR_18': 'e', 'FUNC_12': 'printStackTrace', 'FUNC_13': 'main', 'VAR_19': 'args', 'VAR_20': 'runner'} | java | OOP | 70.42% |
package com.customdatahandler.dto;
import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.customdatahandler.annotation.KeyValuePair;
@XmlRootElement(name = "create-account")
@KeyValuePair
@XmlType
@XmlAccessorType(XmlAccessType.FIELD)
public class CreateAccountForm {
@XmlElement(name = "first-name")
private String firstName;
@XmlElement(name = "last-name")
private String lastName;
private String gender;
@XmlElement(name = "birth-date")
private Date birthDate;
private String email;
private String password;
public CreateAccountForm() {
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public Date getBirthDate() {
return birthDate;
}
public void setBirthDate(Date birthDate) {
this.birthDate = birthDate;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
| package com.customdatahandler.dto;
import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import com.customdatahandler.annotation.KeyValuePair;
@XmlRootElement(name = "create-account")
@KeyValuePair
@XmlType
@XmlAccessorType(XmlAccessType.VAR_0)
public class CreateAccountForm {
@XmlElement(name = "first-name")
private String firstName;
@XmlElement(name = "last-name")
private String lastName;
private String gender;
@XmlElement(name = "birth-date")
private Date birthDate;
private String email;
private String VAR_1;
public CreateAccountForm() {
}
public String FUNC_0() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public Date getBirthDate() {
return birthDate;
}
public void FUNC_1(Date birthDate) {
this.birthDate = birthDate;
}
public String getEmail() {
return email;
}
public void FUNC_2(String email) {
this.email = email;
}
public String getPassword() {
return VAR_1;
}
public void setPassword(String VAR_1) {
this.VAR_1 = VAR_1;
}
}
| 0.158791 | {'VAR_0': 'FIELD', 'VAR_1': 'password', 'FUNC_0': 'getFirstName', 'FUNC_1': 'setBirthDate', 'FUNC_2': 'setEmail'} | java | Hibrido | 100.00% |
package com.tuya.smart.rnsdk.core;
import android.app.Application;
import android.content.Context;
import android.text.TextUtils;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.tuya.smart.home.sdk.TuyaHomeSdk;
import com.tuya.smart.rnsdk.utils.ReactParamsCheck;
import com.tuya.smart.rnsdk.utils.TuyaReactUtils;
import com.tuya.smart.sdk.api.INeedLoginListener;
import com.tuya.smart.sdk.api.IRequestCallback;
import java.util.Arrays;
import java.util.HashMap;
import javax.annotation.Nonnull;
import static com.tuya.smart.rnsdk.utils.Constant.API_REQUEST_ERROR;
import static com.tuya.smart.rnsdk.utils.Constant.APPKEY;
import static com.tuya.smart.rnsdk.utils.Constant.APPSECRET;
import static com.tuya.smart.rnsdk.utils.Constant.DEBUG;
import static com.tuya.smart.rnsdk.utils.Constant.NEEDLOGIN;
public class TuyaCoreModule extends ReactContextBaseJavaModule {
public TuyaCoreModule(@Nonnull ReactApplicationContext reactContext) {
super(reactContext);
}
@Nonnull
@Override
public String getName() {
return "TuyaCoreModule";
}
@ReactMethod
public void initWithoutOptions() {
TuyaHomeSdk.init((Application) getReactApplicationContext().getApplicationContext());
}
@ReactMethod
public void initWithOptions(ReadableMap params) {
if (ReactParamsCheck.checkParams(Arrays.asList(APPKEY, APPSECRET), params)) {
TuyaHomeSdk.init((Application) getReactApplicationContext().getApplicationContext(), params.getString(APPKEY), params.getString(APPSECRET));
}
}
@ReactMethod
public void apiRequest(ReadableMap params, final Promise promise) {
IRequestCallback iRequestCallback = new IRequestCallback() {
@Override
public void onSuccess(Object result) {
if (result instanceof Boolean) {
promise.resolve("success");
return;
}
WritableMap writableMap = TuyaReactUtils.parseToWritableMap(result);
promise.resolve(writableMap);
}
@Override
public void onFailure(String errorCode, String errorMsg) {
promise.reject(errorCode, errorMsg);
}
};
Boolean withoutSession = params.getBoolean("withoutSession");
String apiName = params.getString("apiName");
String apiVersion = params.getString("version");
HashMap postData = TuyaReactUtils.parseToMap(params.getMap("postData"));
if (TextUtils.isEmpty(apiName)) {
promise.reject(API_REQUEST_ERROR, "ApiName is empty");
return;
}
if (withoutSession) {
TuyaHomeSdk.getRequestInstance().requestWithApiNameWithoutSession(apiName, apiVersion, postData, iRequestCallback);
} else {
TuyaHomeSdk.getRequestInstance().requestWithApiName(apiName, apiVersion, postData, iRequestCallback);
}
}
@ReactMethod
public void setOnNeedLoginListener() {
TuyaHomeSdk.setOnNeedLoginListener(new INeedLoginListener() {
@Override
public void onNeedLogin(Context context) {
TuyaReactUtils.sendEvent(getReactApplicationContext(), NEEDLOGIN, null);
}
});
}
@ReactMethod
public void setDebugMode(ReadableMap params) {
if (ReactParamsCheck.checkParams(Arrays.asList(DEBUG), params)) {
TuyaHomeSdk.setDebugMode(params.getBoolean(DEBUG));
}
}
@ReactMethod
public void onDestroy() {
TuyaHomeSdk.onDestroy();
}
}
| package IMPORT_0.tuya.IMPORT_1.IMPORT_2.IMPORT_3;
import IMPORT_4.IMPORT_5.Application;
import IMPORT_4.IMPORT_6.IMPORT_7;
import IMPORT_4.text.IMPORT_8;
import IMPORT_0.IMPORT_9.IMPORT_10.IMPORT_11.IMPORT_12;
import IMPORT_0.IMPORT_9.IMPORT_10.IMPORT_11.IMPORT_13;
import IMPORT_0.IMPORT_9.IMPORT_10.IMPORT_11.ReactContextBaseJavaModule;
import IMPORT_0.IMPORT_9.IMPORT_10.IMPORT_11.ReactMethod;
import IMPORT_0.IMPORT_9.IMPORT_10.IMPORT_11.IMPORT_14;
import IMPORT_0.IMPORT_9.IMPORT_10.IMPORT_11.WritableMap;
import IMPORT_0.tuya.IMPORT_1.IMPORT_15.IMPORT_16.IMPORT_17;
import IMPORT_0.tuya.IMPORT_1.IMPORT_2.IMPORT_18.ReactParamsCheck;
import IMPORT_0.tuya.IMPORT_1.IMPORT_2.IMPORT_18.IMPORT_19;
import IMPORT_0.tuya.IMPORT_1.IMPORT_16.IMPORT_20.IMPORT_21;
import IMPORT_0.tuya.IMPORT_1.IMPORT_16.IMPORT_20.IMPORT_22;
import IMPORT_23.IMPORT_24.IMPORT_25;
import IMPORT_23.IMPORT_24.IMPORT_26;
import javax.IMPORT_27.Nonnull;
import static IMPORT_0.tuya.IMPORT_1.IMPORT_2.IMPORT_18.IMPORT_28.API_REQUEST_ERROR;
import static IMPORT_0.tuya.IMPORT_1.IMPORT_2.IMPORT_18.IMPORT_28.IMPORT_29;
import static IMPORT_0.tuya.IMPORT_1.IMPORT_2.IMPORT_18.IMPORT_28.IMPORT_30;
import static IMPORT_0.tuya.IMPORT_1.IMPORT_2.IMPORT_18.IMPORT_28.IMPORT_31;
import static IMPORT_0.tuya.IMPORT_1.IMPORT_2.IMPORT_18.IMPORT_28.NEEDLOGIN;
public class CLASS_0 extends ReactContextBaseJavaModule {
public CLASS_0(@Nonnull IMPORT_13 reactContext) {
super(reactContext);
}
@Nonnull
@VAR_0
public CLASS_1 FUNC_0() {
return "TuyaCoreModule";
}
@ReactMethod
public void FUNC_1() {
IMPORT_17.FUNC_2((Application) FUNC_3().FUNC_4());
}
@ReactMethod
public void FUNC_5(IMPORT_14 VAR_1) {
if (ReactParamsCheck.FUNC_6(IMPORT_25.FUNC_7(IMPORT_29, IMPORT_30), VAR_1)) {
IMPORT_17.FUNC_2((Application) FUNC_3().FUNC_4(), VAR_1.FUNC_8(IMPORT_29), VAR_1.FUNC_8(IMPORT_30));
}
}
@ReactMethod
public void FUNC_9(IMPORT_14 VAR_1, final IMPORT_12 VAR_2) {
IMPORT_22 iRequestCallback = new IMPORT_22() {
@VAR_0
public void FUNC_10(CLASS_2 result) {
if (result instanceof CLASS_3) {
VAR_2.FUNC_11("success");
return;
}
WritableMap writableMap = IMPORT_19.FUNC_12(result);
VAR_2.FUNC_11(writableMap);
}
@VAR_0
public void onFailure(CLASS_1 VAR_3, CLASS_1 VAR_4) {
VAR_2.FUNC_13(VAR_3, VAR_4);
}
};
CLASS_3 VAR_5 = VAR_1.FUNC_14("withoutSession");
CLASS_1 VAR_6 = VAR_1.FUNC_8("apiName");
CLASS_1 apiVersion = VAR_1.FUNC_8("version");
IMPORT_26 VAR_7 = IMPORT_19.FUNC_15(VAR_1.getMap("postData"));
if (IMPORT_8.FUNC_16(VAR_6)) {
VAR_2.FUNC_13(API_REQUEST_ERROR, "ApiName is empty");
return;
}
if (VAR_5) {
IMPORT_17.FUNC_17().FUNC_18(VAR_6, apiVersion, VAR_7, iRequestCallback);
} else {
IMPORT_17.FUNC_17().requestWithApiName(VAR_6, apiVersion, VAR_7, iRequestCallback);
}
}
@ReactMethod
public void FUNC_19() {
IMPORT_17.FUNC_19(new IMPORT_21() {
@VAR_0
public void FUNC_20(IMPORT_7 VAR_8) {
IMPORT_19.sendEvent(FUNC_3(), NEEDLOGIN, null);
}
});
}
@ReactMethod
public void setDebugMode(IMPORT_14 VAR_1) {
if (ReactParamsCheck.FUNC_6(IMPORT_25.FUNC_7(IMPORT_31), VAR_1)) {
IMPORT_17.setDebugMode(VAR_1.FUNC_14(IMPORT_31));
}
}
@ReactMethod
public void FUNC_21() {
IMPORT_17.FUNC_21();
}
}
| 0.841316 | {'IMPORT_0': 'com', 'IMPORT_1': 'smart', 'IMPORT_2': 'rnsdk', 'IMPORT_3': 'core', 'IMPORT_4': 'android', 'IMPORT_5': 'app', 'IMPORT_6': 'content', 'IMPORT_7': 'Context', 'IMPORT_8': 'TextUtils', 'IMPORT_9': 'facebook', 'IMPORT_10': 'react', 'IMPORT_11': 'bridge', 'IMPORT_12': 'Promise', 'IMPORT_13': 'ReactApplicationContext', 'IMPORT_14': 'ReadableMap', 'IMPORT_15': 'home', 'IMPORT_16': 'sdk', 'IMPORT_17': 'TuyaHomeSdk', 'IMPORT_18': 'utils', 'IMPORT_19': 'TuyaReactUtils', 'IMPORT_20': 'api', 'IMPORT_21': 'INeedLoginListener', 'IMPORT_22': 'IRequestCallback', 'IMPORT_23': 'java', 'IMPORT_24': 'util', 'IMPORT_25': 'Arrays', 'IMPORT_26': 'HashMap', 'IMPORT_27': 'annotation', 'IMPORT_28': 'Constant', 'IMPORT_29': 'APPKEY', 'IMPORT_30': 'APPSECRET', 'IMPORT_31': 'DEBUG', 'CLASS_0': 'TuyaCoreModule', 'VAR_0': 'Override', 'CLASS_1': 'String', 'FUNC_0': 'getName', 'FUNC_1': 'initWithoutOptions', 'FUNC_2': 'init', 'FUNC_3': 'getReactApplicationContext', 'FUNC_4': 'getApplicationContext', 'FUNC_5': 'initWithOptions', 'VAR_1': 'params', 'FUNC_6': 'checkParams', 'FUNC_7': 'asList', 'FUNC_8': 'getString', 'FUNC_9': 'apiRequest', 'VAR_2': 'promise', 'FUNC_10': 'onSuccess', 'CLASS_2': 'Object', 'CLASS_3': 'Boolean', 'FUNC_11': 'resolve', 'FUNC_12': 'parseToWritableMap', 'VAR_3': 'errorCode', 'VAR_4': 'errorMsg', 'FUNC_13': 'reject', 'VAR_5': 'withoutSession', 'FUNC_14': 'getBoolean', 'VAR_6': 'apiName', 'VAR_7': 'postData', 'FUNC_15': 'parseToMap', 'FUNC_16': 'isEmpty', 'FUNC_17': 'getRequestInstance', 'FUNC_18': 'requestWithApiNameWithoutSession', 'FUNC_19': 'setOnNeedLoginListener', 'FUNC_20': 'onNeedLogin', 'VAR_8': 'context', 'FUNC_21': 'onDestroy'} | java | OOP | 38.91% |
/** return the top-level scope (used as return target) */
public ExposedLocals top() {
ExposedLocals l;
for (l = this; l.parent != null; l = l.parent);
return l;
} | /** return the top-level scope (used as return target) */
public ExposedLocals top() {
ExposedLocals VAR_0;
for (VAR_0 = this; VAR_0.VAR_1 != null; VAR_0 = VAR_0.VAR_1);
return VAR_0;
} | 0.298332 | {'VAR_0': 'l', 'VAR_1': 'parent'} | java | Procedural | 100.00% |
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.10.27 at 02:07:42 PM EDT
//
package com.greenenergycorp.openfmb.xml;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
/**
* Weather curve
*
* <p>Java class for WeatherData complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="WeatherData">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="interval" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="source" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="version" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="versionDateTime" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
* <element name="Humidity" type="{http://openfmb.org/xsd/2015/12/openfmb/weathermodule}Humidity" minOccurs="0"/>
* <element name="SunRadiation" type="{http://openfmb.org/xsd/2015/12/openfmb/weathermodule}SunRadiation" minOccurs="0"/>
* <element name="Temperature" type="{http://openfmb.org/xsd/2015/12/openfmb/weathermodule}Temperature" minOccurs="0"/>
* <element name="Wind" type="{http://openfmb.org/xsd/2015/12/openfmb/weathermodule}Wind" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "WeatherData", namespace = "http://openfmb.org/xsd/2015/12/openfmb/weathermodule", propOrder = {
"interval",
"source",
"version",
"versionDateTime",
"humidity",
"sunRadiation",
"temperature",
"wind"
})
@XmlRootElement(name = "WeatherData", namespace = "http://openfmb.org/xsd/2015/12/openfmb/weathermodule")
public class WeatherData
implements Serializable
{
private final static long serialVersionUID = 1L;
protected String interval;
protected String source;
protected String version;
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar versionDateTime;
@XmlElement(name = "Humidity")
protected Humidity humidity;
@XmlElement(name = "SunRadiation")
protected SunRadiation sunRadiation;
@XmlElement(name = "Temperature")
protected Temperature temperature;
@XmlElement(name = "Wind")
protected Wind wind;
/**
* Gets the value of the interval property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getInterval() {
return interval;
}
/**
* Sets the value of the interval property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setInterval(String value) {
this.interval = value;
}
/**
* Gets the value of the source property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getSource() {
return source;
}
/**
* Sets the value of the source property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setSource(String value) {
this.source = value;
}
/**
* Gets the value of the version property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getVersion() {
return version;
}
/**
* Sets the value of the version property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setVersion(String value) {
this.version = value;
}
/**
* Gets the value of the versionDateTime property.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getVersionDateTime() {
return versionDateTime;
}
/**
* Sets the value of the versionDateTime property.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setVersionDateTime(XMLGregorianCalendar value) {
this.versionDateTime = value;
}
/**
* Gets the value of the humidity property.
*
* @return
* possible object is
* {@link Humidity }
*
*/
public Humidity getHumidity() {
return humidity;
}
/**
* Sets the value of the humidity property.
*
* @param value
* allowed object is
* {@link Humidity }
*
*/
public void setHumidity(Humidity value) {
this.humidity = value;
}
/**
* Gets the value of the sunRadiation property.
*
* @return
* possible object is
* {@link SunRadiation }
*
*/
public SunRadiation getSunRadiation() {
return sunRadiation;
}
/**
* Sets the value of the sunRadiation property.
*
* @param value
* allowed object is
* {@link SunRadiation }
*
*/
public void setSunRadiation(SunRadiation value) {
this.sunRadiation = value;
}
/**
* Gets the value of the temperature property.
*
* @return
* possible object is
* {@link Temperature }
*
*/
public Temperature getTemperature() {
return temperature;
}
/**
* Sets the value of the temperature property.
*
* @param value
* allowed object is
* {@link Temperature }
*
*/
public void setTemperature(Temperature value) {
this.temperature = value;
}
/**
* Gets the value of the wind property.
*
* @return
* possible object is
* {@link Wind }
*
*/
public Wind getWind() {
return wind;
}
/**
* Sets the value of the wind property.
*
* @param value
* allowed object is
* {@link Wind }
*
*/
public void setWind(Wind value) {
this.wind = value;
}
}
| //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2016.10.27 at 02:07:42 PM EDT
//
package com.IMPORT_0.openfmb.IMPORT_1;
import java.IMPORT_2.IMPORT_3;
import javax.IMPORT_1.bind.annotation.IMPORT_4;
import javax.IMPORT_1.bind.annotation.XmlAccessorType;
import javax.IMPORT_1.bind.annotation.IMPORT_5;
import javax.IMPORT_1.bind.annotation.IMPORT_6;
import javax.IMPORT_1.bind.annotation.IMPORT_7;
import javax.IMPORT_1.bind.annotation.IMPORT_8;
import javax.IMPORT_1.IMPORT_9.XMLGregorianCalendar;
/**
* Weather curve
*
* <p>Java class for WeatherData complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="WeatherData">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="interval" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="source" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="version" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* <element name="versionDateTime" type="{http://www.w3.org/2001/XMLSchema}dateTime" minOccurs="0"/>
* <element name="Humidity" type="{http://openfmb.org/xsd/2015/12/openfmb/weathermodule}Humidity" minOccurs="0"/>
* <element name="SunRadiation" type="{http://openfmb.org/xsd/2015/12/openfmb/weathermodule}SunRadiation" minOccurs="0"/>
* <element name="Temperature" type="{http://openfmb.org/xsd/2015/12/openfmb/weathermodule}Temperature" minOccurs="0"/>
* <element name="Wind" type="{http://openfmb.org/xsd/2015/12/openfmb/weathermodule}Wind" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(IMPORT_4.FIELD)
@IMPORT_8(name = "WeatherData", namespace = "http://openfmb.org/xsd/2015/12/openfmb/weathermodule", propOrder = {
"interval",
"source",
"version",
"versionDateTime",
"humidity",
"sunRadiation",
"temperature",
"wind"
})
@IMPORT_6(name = "WeatherData", namespace = "http://openfmb.org/xsd/2015/12/openfmb/weathermodule")
public class CLASS_0
implements IMPORT_3
{
private final static long VAR_0 = 1L;
protected CLASS_1 interval;
protected CLASS_1 VAR_1;
protected CLASS_1 VAR_2;
@IMPORT_7(name = "dateTime")
protected XMLGregorianCalendar VAR_3;
@IMPORT_5(name = "Humidity")
protected CLASS_2 VAR_4;
@IMPORT_5(name = "SunRadiation")
protected SunRadiation sunRadiation;
@IMPORT_5(name = "Temperature")
protected CLASS_3 VAR_5;
@IMPORT_5(name = "Wind")
protected Wind VAR_6;
/**
* Gets the value of the interval property.
*
* @return
* possible object is
* {@link String }
*
*/
public CLASS_1 getInterval() {
return interval;
}
/**
* Sets the value of the interval property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setInterval(CLASS_1 VAR_7) {
this.interval = VAR_7;
}
/**
* Gets the value of the source property.
*
* @return
* possible object is
* {@link String }
*
*/
public CLASS_1 getSource() {
return VAR_1;
}
/**
* Sets the value of the source property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setSource(CLASS_1 VAR_7) {
this.VAR_1 = VAR_7;
}
/**
* Gets the value of the version property.
*
* @return
* possible object is
* {@link String }
*
*/
public CLASS_1 FUNC_0() {
return VAR_2;
}
/**
* Sets the value of the version property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setVersion(CLASS_1 VAR_7) {
this.VAR_2 = VAR_7;
}
/**
* Gets the value of the versionDateTime property.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getVersionDateTime() {
return VAR_3;
}
/**
* Sets the value of the versionDateTime property.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void FUNC_1(XMLGregorianCalendar VAR_7) {
this.VAR_3 = VAR_7;
}
/**
* Gets the value of the humidity property.
*
* @return
* possible object is
* {@link Humidity }
*
*/
public CLASS_2 getHumidity() {
return VAR_4;
}
/**
* Sets the value of the humidity property.
*
* @param value
* allowed object is
* {@link Humidity }
*
*/
public void FUNC_2(CLASS_2 VAR_7) {
this.VAR_4 = VAR_7;
}
/**
* Gets the value of the sunRadiation property.
*
* @return
* possible object is
* {@link SunRadiation }
*
*/
public SunRadiation getSunRadiation() {
return sunRadiation;
}
/**
* Sets the value of the sunRadiation property.
*
* @param value
* allowed object is
* {@link SunRadiation }
*
*/
public void setSunRadiation(SunRadiation VAR_7) {
this.sunRadiation = VAR_7;
}
/**
* Gets the value of the temperature property.
*
* @return
* possible object is
* {@link Temperature }
*
*/
public CLASS_3 getTemperature() {
return VAR_5;
}
/**
* Sets the value of the temperature property.
*
* @param value
* allowed object is
* {@link Temperature }
*
*/
public void FUNC_3(CLASS_3 VAR_7) {
this.VAR_5 = VAR_7;
}
/**
* Gets the value of the wind property.
*
* @return
* possible object is
* {@link Wind }
*
*/
public Wind FUNC_4() {
return VAR_6;
}
/**
* Sets the value of the wind property.
*
* @param value
* allowed object is
* {@link Wind }
*
*/
public void setWind(Wind VAR_7) {
this.VAR_6 = VAR_7;
}
}
| 0.433372 | {'IMPORT_0': 'greenenergycorp', 'IMPORT_1': 'xml', 'IMPORT_2': 'io', 'IMPORT_3': 'Serializable', 'IMPORT_4': 'XmlAccessType', 'IMPORT_5': 'XmlElement', 'IMPORT_6': 'XmlRootElement', 'IMPORT_7': 'XmlSchemaType', 'IMPORT_8': 'XmlType', 'IMPORT_9': 'datatype', 'CLASS_0': 'WeatherData', 'VAR_0': 'serialVersionUID', 'CLASS_1': 'String', 'VAR_1': 'source', 'VAR_2': 'version', 'VAR_3': 'versionDateTime', 'CLASS_2': 'Humidity', 'VAR_4': 'humidity', 'CLASS_3': 'Temperature', 'VAR_5': 'temperature', 'VAR_6': 'wind', 'VAR_7': 'value', 'FUNC_0': 'getVersion', 'FUNC_1': 'setVersionDateTime', 'FUNC_2': 'setHumidity', 'FUNC_3': 'setTemperature', 'FUNC_4': 'getWind'} | java | Hibrido | 29.93% |
/**
* Tags have only a name.
*
* This participates in a many-many relationship with solution via a join table.
* The relationship is mapped via annotations on MLPSolution (unidirectional).
*/
@Entity
@Table(name = "C_SOLUTION_TAG")
public class MLPTag implements MLPEntity, Serializable {
private static final long serialVersionUID = -288462280366502647L;
@Id
@Column(name = "TAG", nullable = false, updatable = false, columnDefinition = "VARCHAR(32)")
@Size(max = 32)
@ApiModelProperty(required = true, example = "Classification")
private String tag;
/**
* No-arg constructor
*/
public MLPTag() {
// no-arg constructor
}
/**
* This constructor accepts the required fields; i.e., the minimum that the user
* must supply to create a valid instance.
*
* @param tag
* The tag
*/
public MLPTag(String tag) {
if (tag == null || tag.length() == 0)
throw new IllegalArgumentException("Null/empty not permitted");
this.tag = tag;
}
/**
* Copy constructor
*
* @param that
* Instance to copy
*/
public MLPTag(MLPTag that) {
this.tag = that.tag;
}
public String getTag() {
return tag;
}
public void setTag(String tag) {
this.tag = tag;
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (!(that instanceof MLPTag))
return false;
MLPTag thatObj = (MLPTag) that;
return Objects.equals(tag, thatObj.tag);
}
@Override
public int hashCode() {
return Objects.hash(tag);
}
@Override
public String toString() {
return this.getClass().getName() + "[tag=" + tag + "]";
}
} | /**
* Tags have only a name.
*
* This participates in a many-many relationship with solution via a join table.
* The relationship is mapped via annotations on MLPSolution (unidirectional).
*/
@VAR_0
@VAR_1(name = "C_SOLUTION_TAG")
public class CLASS_0 implements MLPEntity, CLASS_1 {
private static final long VAR_2 = -288462280366502647L;
@VAR_3
@Column(name = "TAG", nullable = false, updatable = false, VAR_4 = "VARCHAR(32)")
@Size(VAR_5 = 32)
@VAR_6(VAR_7 = true, VAR_8 = "Classification")
private CLASS_2 VAR_9;
/**
* No-arg constructor
*/
public CLASS_0() {
// no-arg constructor
}
/**
* This constructor accepts the required fields; i.e., the minimum that the user
* must supply to create a valid instance.
*
* @param tag
* The tag
*/
public CLASS_0(CLASS_2 VAR_9) {
if (VAR_9 == null || VAR_9.length() == 0)
throw new CLASS_3("Null/empty not permitted");
this.VAR_9 = VAR_9;
}
/**
* Copy constructor
*
* @param that
* Instance to copy
*/
public CLASS_0(CLASS_0 that) {
this.VAR_9 = that.VAR_9;
}
public CLASS_2 FUNC_0() {
return VAR_9;
}
public void setTag(CLASS_2 VAR_9) {
this.VAR_9 = VAR_9;
}
@VAR_10
public boolean FUNC_1(CLASS_4 that) {
if (that == null)
return false;
if (!(that instanceof CLASS_0))
return false;
CLASS_0 VAR_11 = (CLASS_0) that;
return VAR_12.FUNC_1(VAR_9, VAR_11.VAR_9);
}
@VAR_10
public int hashCode() {
return VAR_12.FUNC_2(VAR_9);
}
@VAR_10
public CLASS_2 FUNC_3() {
return this.FUNC_4().FUNC_5() + "[tag=" + VAR_9 + "]";
}
} | 0.664014 | {'VAR_0': 'Entity', 'VAR_1': 'Table', 'CLASS_0': 'MLPTag', 'CLASS_1': 'Serializable', 'VAR_2': 'serialVersionUID', 'VAR_3': 'Id', 'VAR_4': 'columnDefinition', 'VAR_5': 'max', 'VAR_6': 'ApiModelProperty', 'VAR_7': 'required', 'VAR_8': 'example', 'CLASS_2': 'String', 'VAR_9': 'tag', 'CLASS_3': 'IllegalArgumentException', 'FUNC_0': 'getTag', 'VAR_10': 'Override', 'FUNC_1': 'equals', 'CLASS_4': 'Object', 'VAR_11': 'thatObj', 'VAR_12': 'Objects', 'FUNC_2': 'hash', 'FUNC_3': 'toString', 'FUNC_4': 'getClass', 'FUNC_5': 'getName'} | java | Hibrido | 49.18% |
package players;
import util.*;
import board.*;
public interface Player {
public Line makePlay(Board board, Player opponent, Line oppPlay, Clock clock);
public String teamName();
public java.awt.Color getColor();
public int getId();
public String toString();
} |
package players;
import util.*;
import board.*;
public interface Player {
public Line makePlay(Board board, Player opponent, Line oppPlay, Clock clock);
public String teamName();
public java.awt.Color getColor();
public int getId();
public String toString();
} | 0.053594 | {} | java | Texto | 21.74% |
/**
* Created by bmorrise on 2/23/19.
*/
public class Utils {
public static List<String>
validExtensions = Arrays
.asList( "3g2", "3ga", "3gp", "7z", "aa", "aac", "ac", "accdb", "accdt", "ace", "adn", "ai", "aif", "aifc", "aiff",
"ait", "amr", "ani", "apk", "app", "applescript", "asax", "asc", "ascx", "asf", "ash", "ashx", "asm", "asmx",
"asp", "aspx", "asx", "au", "aup", "avi", "axd", "aze", "bak", "bash", "bat", "bin", "blank", "bmp", "bowerrc",
"bpg", "browser", "bz2", "bzempty", "c", "cab", "cad", "caf", "cal", "catalog", "cd", "cdda", "cer", "cfg", "cfm",
"cfml", "cgi", "chm", "class", "cmd", "code-workspace", "codekit", "coffee", "coffeelintignore", "com", "compile",
"conf", "config", "cpp", "cptx", "cr2", "crdownload", "crt", "crypt", "cs", "csh", "cson", "csproj", "css", "csv",
"cue", "cur", "dart", "dat", "data", "db", "dbf", "deb", "default", "dgn", "dist", "diz", "dll", "dmg", "dng",
"doc", "docb", "docm", "docx", "dot", "dotm", "dotx", "download", "dpj", "ds_store", "dsn", "dtd", "dwg", "dxf",
"editorconfig", "el", "elf", "eml", "enc", "eot", "eps", "epub", "eslintignore", "exe", "f4v", "fax", "fb2",
"fla", "flac", "flv", "fnt", "folder", "fon", "gadget", "gdp", "gem", "gif", "gitattributes", "gitignore", "go",
"gpg", "gpl", "gradle", "gz", "h", "handlebars", "hbs", "heic", "hlp", "hs", "hsl", "htm", "html", "ibooks",
"icns", "ico", "ics", "idx", "iff", "ifo", "image", "img", "iml", "in", "inc", "indd", "inf", "info", "ini",
"inv", "iso", "j2", "jar", "java", "jpe", "jpeg", "jpg", "js", "json", "jsp", "jsx", "key", "kf8", "kjb", "kmk",
"ksh", "kt", "ktr", "kts", "kup", "less", "lex", "licx", "lisp", "lit", "lnk", "lock", "log", "lua", "m", "m2v",
"m3u", "m3u8", "m4", "m4a", "m4r", "m4v", "map", "master", "mc", "md", "mdb", "mdf", "me", "mi", "mid", "midi",
"mk", "mkv", "mm", "mng", "mo", "mobi", "mod", "mov", "mp2", "mp3", "mp4", "mpa", "mpd", "mpe", "mpeg", "mpg",
"mpga", "mpp", "mpt", "msg", "msi", "msu", "nef", "nes", "nfo", "nix", "npmignore", "ocx", "odb", "ods", "odt",
"ogg", "ogv", "ost", "otf", "ott", "ova", "ovf", "p12", "p7b", "pages", "part", "pcd", "pdb", "pdf", "pem", "pfx",
"pgp", "ph", "phar", "php", "pid", "pkg", "pl", "plist", "pm", "png", "po", "pom", "pot", "potx", "pps", "ppsx",
"ppt", "pptm", "pptx", "prop", "ps", "ps1", "psd", "psp", "pst", "pub", "py", "pyc", "qt", "ra", "ram", "rar",
"raw", "rb", "rdf", "rdl", "reg", "resx", "retry", "rm", "rom", "rpm", "rpt", "rsa", "rss", "rst", "rtf", "ru",
"rub", "sass", "scss", "sdf", "sed", "sh", "sit", "sitemap", "skin", "sldm", "sldx", "sln", "sol", "sphinx",
"sql", "sqlite", "step", "stl", "svg", "swd", "swf", "swift", "swp", "sys", "tar", "tax", "tcsh", "tex",
"tfignore", "tga", "tgz", "tif", "tiff", "tmp", "tmx", "torrent", "tpl", "ts", "tsv", "ttf", "twig", "txt", "udf",
"vb", "vbproj", "vbs", "vcd", "vcf", "vcs", "vdi", "vdx", "vmdk", "vob", "vox", "vscodeignore", "vsd", "vss",
"vst", "vsx", "vtx", "war", "wav", "wbk", "webinfo", "webm", "webp", "wma", "wmf", "wmv", "woff", "woff2", "wps",
"wsf", "xaml", "xcf", "xfl", "xlm", "xls", "xlsm", "xlsx", "xlt", "xltm", "xltx", "xml", "xpi", "xps", "xrb",
"xsd", "xsl", "xspf", "xz", "yaml", "yml", "z", "zip", "zsh" );
public static boolean matches( String name, String filters ) {
return filters == null || name.matches( filters.replace( ".", ".*\\." ) );
}
public static String getExtension( String path ) {
return path.substring( path.lastIndexOf( "." ) + 1, path.length() );
}
public static boolean isValidExtension( String extension ) {
return validExtensions.contains( extension );
}
public static String getParent( String path ) {
return path.substring( 0, path.lastIndexOf( "/" ) );
}
public static String getName( String path ) {
return path.substring( path.lastIndexOf( "/" ), path.length() );
}
} | /**
* Created by bmorrise on 2/23/19.
*/
public class CLASS_0 {
public static CLASS_1<CLASS_2>
VAR_0 = VAR_1
.FUNC_0( "3g2", "3ga", "3gp", "7z", "aa", "aac", "ac", "accdb", "accdt", "ace", "adn", "ai", "aif", "aifc", "aiff",
"ait", "amr", "ani", "apk", "app", "applescript", "asax", "asc", "ascx", "asf", "ash", "ashx", "asm", "asmx",
"asp", "aspx", "asx", "au", "aup", "avi", "axd", "aze", "bak", "bash", "bat", "bin", "blank", "bmp", "bowerrc",
"bpg", "browser", "bz2", "bzempty", "c", "cab", "cad", "caf", "cal", "catalog", "cd", "cdda", "cer", "cfg", "cfm",
"cfml", "cgi", "chm", "class", "cmd", "code-workspace", "codekit", "coffee", "coffeelintignore", "com", "compile",
"conf", "config", "cpp", "cptx", "cr2", "crdownload", "crt", "crypt", "cs", "csh", "cson", "csproj", "css", "csv",
"cue", "cur", "dart", "dat", "data", "db", "dbf", "deb", "default", "dgn", "dist", "diz", "dll", "dmg", "dng",
"doc", "docb", "docm", "docx", "dot", "dotm", "dotx", "download", "dpj", "ds_store", "dsn", "dtd", "dwg", "dxf",
"editorconfig", "el", "elf", "eml", "enc", "eot", "eps", "epub", "eslintignore", "exe", "f4v", "fax", "fb2",
"fla", "flac", "flv", "fnt", "folder", "fon", "gadget", "gdp", "gem", "gif", "gitattributes", "gitignore", "go",
"gpg", "gpl", "gradle", "gz", "h", "handlebars", "hbs", "heic", "hlp", "hs", "hsl", "htm", "html", "ibooks",
"icns", "ico", "ics", "idx", "iff", "ifo", "image", "img", "iml", "in", "inc", "indd", "inf", "info", "ini",
"inv", "iso", "j2", "jar", "java", "jpe", "jpeg", "jpg", "js", "json", "jsp", "jsx", "key", "kf8", "kjb", "kmk",
"ksh", "kt", "ktr", "kts", "kup", "less", "lex", "licx", "lisp", "lit", "lnk", "lock", "log", "lua", "m", "m2v",
"m3u", "m3u8", "m4", "m4a", "m4r", "m4v", "map", "master", "mc", "md", "mdb", "mdf", "me", "mi", "mid", "midi",
"mk", "mkv", "mm", "mng", "mo", "mobi", "mod", "mov", "mp2", "mp3", "mp4", "mpa", "mpd", "mpe", "mpeg", "mpg",
"mpga", "mpp", "mpt", "msg", "msi", "msu", "nef", "nes", "nfo", "nix", "npmignore", "ocx", "odb", "ods", "odt",
"ogg", "ogv", "ost", "otf", "ott", "ova", "ovf", "p12", "p7b", "pages", "part", "pcd", "pdb", "pdf", "pem", "pfx",
"pgp", "ph", "phar", "php", "pid", "pkg", "pl", "plist", "pm", "png", "po", "pom", "pot", "potx", "pps", "ppsx",
"ppt", "pptm", "pptx", "prop", "ps", "ps1", "psd", "psp", "pst", "pub", "py", "pyc", "qt", "ra", "ram", "rar",
"raw", "rb", "rdf", "rdl", "reg", "resx", "retry", "rm", "rom", "rpm", "rpt", "rsa", "rss", "rst", "rtf", "ru",
"rub", "sass", "scss", "sdf", "sed", "sh", "sit", "sitemap", "skin", "sldm", "sldx", "sln", "sol", "sphinx",
"sql", "sqlite", "step", "stl", "svg", "swd", "swf", "swift", "swp", "sys", "tar", "tax", "tcsh", "tex",
"tfignore", "tga", "tgz", "tif", "tiff", "tmp", "tmx", "torrent", "tpl", "ts", "tsv", "ttf", "twig", "txt", "udf",
"vb", "vbproj", "vbs", "vcd", "vcf", "vcs", "vdi", "vdx", "vmdk", "vob", "vox", "vscodeignore", "vsd", "vss",
"vst", "vsx", "vtx", "war", "wav", "wbk", "webinfo", "webm", "webp", "wma", "wmf", "wmv", "woff", "woff2", "wps",
"wsf", "xaml", "xcf", "xfl", "xlm", "xls", "xlsm", "xlsx", "xlt", "xltm", "xltx", "xml", "xpi", "xps", "xrb",
"xsd", "xsl", "xspf", "xz", "yaml", "yml", "z", "zip", "zsh" );
public static boolean FUNC_1( CLASS_2 VAR_2, CLASS_2 VAR_3 ) {
return VAR_3 == null || VAR_2.FUNC_1( VAR_3.FUNC_2( ".", ".*\\." ) );
}
public static CLASS_2 FUNC_3( CLASS_2 VAR_4 ) {
return VAR_4.FUNC_4( VAR_4.FUNC_5( "." ) + 1, VAR_4.FUNC_6() );
}
public static boolean FUNC_7( CLASS_2 VAR_5 ) {
return VAR_0.FUNC_8( VAR_5 );
}
public static CLASS_2 FUNC_9( CLASS_2 VAR_4 ) {
return VAR_4.FUNC_4( 0, VAR_4.FUNC_5( "/" ) );
}
public static CLASS_2 FUNC_10( CLASS_2 VAR_4 ) {
return VAR_4.FUNC_4( VAR_4.FUNC_5( "/" ), VAR_4.FUNC_6() );
}
} | 0.941475 | {'CLASS_0': 'Utils', 'CLASS_1': 'List', 'CLASS_2': 'String', 'VAR_0': 'validExtensions', 'VAR_1': 'Arrays', 'FUNC_0': 'asList', 'FUNC_1': 'matches', 'VAR_2': 'name', 'VAR_3': 'filters', 'FUNC_2': 'replace', 'FUNC_3': 'getExtension', 'VAR_4': 'path', 'FUNC_4': 'substring', 'FUNC_5': 'lastIndexOf', 'FUNC_6': 'length', 'FUNC_7': 'isValidExtension', 'VAR_5': 'extension', 'FUNC_8': 'contains', 'FUNC_9': 'getParent', 'FUNC_10': 'getName'} | java | error | 0 |
package mx.unam.ciencias.icc;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
/**
* Clase abstracta para bases de datos genéricas. Provee métodos para agregar y
* eliminar registros, y para guardarse y cargarse de una entrada y salida
* dados.
*
* Las clases que extiendan a BaseDeDatos deben implementar el método {@link
* #creaRegistro}, que crea un registro genérico en blanco. También deben
* implementar el método {@link #buscaRegistros} para hacer consultas en la base
* de datos.
*/
public abstract class BaseDeDatos<T extends Registro> {
/** Lista de registros en la base de datos. */
protected Lista<T> registros;
/** Lista de escuchas de la base de datos. */
protected Lista<EscuchaBaseDeDatos<T>> escuchas;
/**
* Constructor único.
*/
public BaseDeDatos() {
registros= new Lista<T>();
escuchas= new Lista<EscuchaBaseDeDatos<T>>();
// Aquí va su código.
}
/**
* Regresa el número de registros en la base de datos.
* @return el número de registros en la base de datos.
*/
public int getNumRegistros() {
return registros.getLongitud();
// Aquí va su código.
}
/**
* Regresa una lista con los registros en la base de datos. Modificar esta
* lista no cambia a la información en la base de datos.
* @return una lista con los registros en la base de datos.
*/
public Lista<T> getRegistros() {
return registros.copia();
// Aquí va su código.
}
/**
* Agrega el registro recibido a la base de datos.
* @param registro el registro que hay que agregar a la base de datos.
*/
public void agregaRegistro(T registro) {
registros.agregaFinal(registro);
for(EscuchaBaseDeDatos<T> escucha: escuchas){
escucha.baseDeDatosModificada(EventoBaseDeDatos.REGISTRO_AGREGADO,registro);}
// Aquí va su código.
}
/**
* Elimina el registro recibido de la base de datos.
* @param registro el registro que hay que eliminar de la base de datos.
*/
public void eliminaRegistro(T registro) {
registros.elimina(registro);
for(EscuchaBaseDeDatos<T> escucha: escuchas){
escucha.baseDeDatosModificada(EventoBaseDeDatos.REGISTRO_ELIMINADO,registro);}
// Aquí va su código.
}
/**
* Guarda todos los registros en la base de datos en la salida recibida.
* @param out la salida donde hay que guardar los registos.
* @throws IOException si ocurre un error de entrada/salida.
*/
public void guarda(BufferedWriter out) throws IOException {
for (T r : registros)
r.guarda(out);
// Aquí va su código.
}
/**
* Guarda los registros de la entrada recibida en la base de datos. Si antes
* de llamar el método había registros en la base de datos, estos son
* eliminados.
* @param in la entrada de donde hay que cargar los registos.
* @throws IOException si ocurre un error de entrada/salida.
*/
public void carga(BufferedReader in) throws IOException {
registros.limpia();
for(EscuchaBaseDeDatos<T> escucha: escuchas){
escucha.baseDeDatosModificada(EventoBaseDeDatos.BASE_LIMPIADA,null);}
do{
T r=creaRegistro();
if(!r.carga(in))
break;
registros.agregaFinal(r);
for(EscuchaBaseDeDatos<T> escucha: escuchas){
escucha.baseDeDatosModificada(EventoBaseDeDatos.REGISTRO_AGREGADO,r);}
}while(true);
// Aquí va su código.
}
/**
* Crea un registro en blanco.
* @return un registro en blanco.
*/
public abstract T creaRegistro();
/**
* Busca registros por un campo específico.
* @param campo el campo del registro por el cuál buscar.
* @param texto el texto a buscar.
* @return una lista con los registros tales que en el campo especificado
* contienen el texto recibido.
* @throws IllegalArgumentException si el campo no es válido.
*/
public abstract Lista<T> buscaRegistros(String campo, String texto);
/**
* Limpia la base de datos.
*/
public void limpia() {
registros.limpia();
for(EscuchaBaseDeDatos<T> escucha: escuchas){
escucha.baseDeDatosModificada(EventoBaseDeDatos.BASE_LIMPIADA,null);}
// Aquí va su código.
}
/**
* Agrega un escucha a la base de datos.
* @param escucha el escucha a agregar.
*/
public void agregaEscucha(EscuchaBaseDeDatos<T> escucha) {
escuchas.agregaFinal(escucha);
// Aquí va su código.
}
}
| package IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3;
import IMPORT_4.IMPORT_5.IMPORT_6;
import IMPORT_4.IMPORT_5.IMPORT_7;
import IMPORT_4.IMPORT_5.IMPORT_8;
/**
* Clase abstracta para bases de datos genéricas. Provee métodos para agregar y
* eliminar registros, y para guardarse y cargarse de una entrada y salida
* dados.
*
* Las clases que extiendan a BaseDeDatos deben implementar el método {@link
* #creaRegistro}, que crea un registro genérico en blanco. También deben
* implementar el método {@link #buscaRegistros} para hacer consultas en la base
* de datos.
*/
public abstract class CLASS_0<CLASS_1 extends CLASS_2> {
/** Lista de registros en la base de datos. */
protected Lista<CLASS_1> VAR_0;
/** Lista de escuchas de la base de datos. */
protected Lista<CLASS_3<CLASS_1>> VAR_1;
/**
* Constructor único.
*/
public CLASS_0() {
VAR_0= new Lista<CLASS_1>();
VAR_1= new Lista<CLASS_3<CLASS_1>>();
// Aquí va su código.
}
/**
* Regresa el número de registros en la base de datos.
* @return el número de registros en la base de datos.
*/
public int FUNC_0() {
return VAR_0.FUNC_1();
// Aquí va su código.
}
/**
* Regresa una lista con los registros en la base de datos. Modificar esta
* lista no cambia a la información en la base de datos.
* @return una lista con los registros en la base de datos.
*/
public Lista<CLASS_1> FUNC_2() {
return VAR_0.FUNC_3();
// Aquí va su código.
}
/**
* Agrega el registro recibido a la base de datos.
* @param registro el registro que hay que agregar a la base de datos.
*/
public void FUNC_4(CLASS_1 VAR_2) {
VAR_0.FUNC_5(VAR_2);
for(CLASS_3<CLASS_1> VAR_3: VAR_1){
VAR_3.FUNC_6(VAR_4.VAR_5,VAR_2);}
// Aquí va su código.
}
/**
* Elimina el registro recibido de la base de datos.
* @param registro el registro que hay que eliminar de la base de datos.
*/
public void FUNC_7(CLASS_1 VAR_2) {
VAR_0.FUNC_8(VAR_2);
for(CLASS_3<CLASS_1> VAR_3: VAR_1){
VAR_3.FUNC_6(VAR_4.VAR_6,VAR_2);}
// Aquí va su código.
}
/**
* Guarda todos los registros en la base de datos en la salida recibida.
* @param out la salida donde hay que guardar los registos.
* @throws IOException si ocurre un error de entrada/salida.
*/
public void FUNC_9(IMPORT_7 VAR_7) throws IMPORT_8 {
for (CLASS_1 VAR_8 : VAR_0)
VAR_8.FUNC_9(VAR_7);
// Aquí va su código.
}
/**
* Guarda los registros de la entrada recibida en la base de datos. Si antes
* de llamar el método había registros en la base de datos, estos son
* eliminados.
* @param in la entrada de donde hay que cargar los registos.
* @throws IOException si ocurre un error de entrada/salida.
*/
public void FUNC_10(IMPORT_6 VAR_9) throws IMPORT_8 {
VAR_0.FUNC_11();
for(CLASS_3<CLASS_1> VAR_3: VAR_1){
VAR_3.FUNC_6(VAR_4.VAR_10,null);}
do{
CLASS_1 VAR_8=FUNC_12();
if(!VAR_8.FUNC_10(VAR_9))
break;
VAR_0.FUNC_5(VAR_8);
for(CLASS_3<CLASS_1> VAR_3: VAR_1){
VAR_3.FUNC_6(VAR_4.VAR_5,VAR_8);}
}while(true);
// Aquí va su código.
}
/**
* Crea un registro en blanco.
* @return un registro en blanco.
*/
public abstract CLASS_1 FUNC_12();
/**
* Busca registros por un campo específico.
* @param campo el campo del registro por el cuál buscar.
* @param texto el texto a buscar.
* @return una lista con los registros tales que en el campo especificado
* contienen el texto recibido.
* @throws IllegalArgumentException si el campo no es válido.
*/
public abstract Lista<CLASS_1> FUNC_13(CLASS_4 VAR_11, CLASS_4 VAR_12);
/**
* Limpia la base de datos.
*/
public void FUNC_11() {
VAR_0.FUNC_11();
for(CLASS_3<CLASS_1> VAR_3: VAR_1){
VAR_3.FUNC_6(VAR_4.VAR_10,null);}
// Aquí va su código.
}
/**
* Agrega un escucha a la base de datos.
* @param escucha el escucha a agregar.
*/
public void FUNC_14(CLASS_3<CLASS_1> VAR_3) {
VAR_1.FUNC_5(VAR_3);
// Aquí va su código.
}
}
| 0.966634 | {'IMPORT_0': 'mx', 'IMPORT_1': 'unam', 'IMPORT_2': 'ciencias', 'IMPORT_3': 'icc', 'IMPORT_4': 'java', 'IMPORT_5': 'io', 'IMPORT_6': 'BufferedReader', 'IMPORT_7': 'BufferedWriter', 'IMPORT_8': 'IOException', 'CLASS_0': 'BaseDeDatos', 'CLASS_1': 'T', 'CLASS_2': 'Registro', 'VAR_0': 'registros', 'CLASS_3': 'EscuchaBaseDeDatos', 'VAR_1': 'escuchas', 'FUNC_0': 'getNumRegistros', 'FUNC_1': 'getLongitud', 'FUNC_2': 'getRegistros', 'FUNC_3': 'copia', 'FUNC_4': 'agregaRegistro', 'VAR_2': 'registro', 'FUNC_5': 'agregaFinal', 'VAR_3': 'escucha', 'FUNC_6': 'baseDeDatosModificada', 'VAR_4': 'EventoBaseDeDatos', 'VAR_5': 'REGISTRO_AGREGADO', 'FUNC_7': 'eliminaRegistro', 'FUNC_8': 'elimina', 'VAR_6': 'REGISTRO_ELIMINADO', 'FUNC_9': 'guarda', 'VAR_7': 'out', 'VAR_8': 'r', 'FUNC_10': 'carga', 'VAR_9': 'in', 'FUNC_11': 'limpia', 'VAR_10': 'BASE_LIMPIADA', 'FUNC_12': 'creaRegistro', 'FUNC_13': 'buscaRegistros', 'CLASS_4': 'String', 'VAR_11': 'campo', 'VAR_12': 'texto', 'FUNC_14': 'agregaEscucha'} | java | Texto | 8.15% |
/**
*
* @author Dan Leehr <[email protected]>
*/
public abstract class ContextUnitTest {
protected Context context;
private static DSpaceKernelImpl kernel;
@Before
public void setUp() {
try {
this.context = new Context();
context.turnOffAuthorisationSystem();
} catch (SQLException ex) {
fail("Unable to instantiate context " + ex);
}
}
@BeforeClass
public static void setupClass() {
kernel = DSpaceKernelInit.getKernel(null);
if(!kernel.isRunning()) {
kernel.start(ConfigurationManager.getProperty("dspace.dir"));
}
}
@After
public void tearDown() {
try {
this.context.complete();
} catch (SQLException ex) {
fail("Unable to tear down context " + ex);
}
}
@AfterClass
public static void tearDownClass() {
kernel.destroy();
}
} | /**
*
* @author Dan Leehr <[email protected]>
*/
public abstract class CLASS_0 {
protected Context VAR_0;
private static DSpaceKernelImpl kernel;
@Before
public void FUNC_0() {
try {
this.VAR_0 = new Context();
VAR_0.turnOffAuthorisationSystem();
} catch (CLASS_1 ex) {
fail("Unable to instantiate context " + ex);
}
}
@VAR_1
public static void setupClass() {
kernel = DSpaceKernelInit.getKernel(null);
if(!kernel.isRunning()) {
kernel.start(ConfigurationManager.getProperty("dspace.dir"));
}
}
@After
public void FUNC_1() {
try {
this.VAR_0.complete();
} catch (CLASS_1 ex) {
fail("Unable to tear down context " + ex);
}
}
@AfterClass
public static void tearDownClass() {
kernel.destroy();
}
} | 0.359749 | {'CLASS_0': 'ContextUnitTest', 'VAR_0': 'context', 'FUNC_0': 'setUp', 'CLASS_1': 'SQLException', 'VAR_1': 'BeforeClass', 'FUNC_1': 'tearDown'} | java | OOP | 56.45% |
/**
* Created by lauril on 3/8/17.
*/
public class BlePacket implements Serializable {
private final static int INDEX = 0;
private final static int LENGTH = 1;
private final static int FLAGS = 2;
private final static int protocol_offset = 3;
//Packet Structure
private int indx=0;
private int length=0;
private int flags = 0;
private byte[] data;
//addons not serializible to out/in
private String address;
private boolean last = false;
public static final int FLAG_LAST = 1;
public BlePacket(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic){
this(characteristic.getValue(), gatt.getDevice().getAddress());
}
private final static String TAG = BlePacket.class.getSimpleName();
private BlePacket(byte[] data, String device_address){
this.indx = getIndex(data);
this.length = getLength(data);
this.flags = getFlags(data);
this.last = (this.flags & FLAG_LAST) == FLAG_LAST;
this.data = ByteWork.getBytesSize(data, protocol_offset, this.length);
this.address = device_address;
}
//This is used to activate notifications
//TODO: needs protocol ID and so on
public BlePacket(byte[] data){
this.data = data;
}
private void setIndx(int d) {this.indx = d ;}
private void setLast(int l) {this.flags = l; this.last = (FLAG_LAST & this.flags) == FLAG_LAST; }
private void setLength(int l) {this.length = l; }
public void setData(byte[] d) {this.data = d ;}
public byte[] getData(){ return data; }
public String getAddress(){ return address; }
public boolean isLast() {return this.last ; }
public void setAddress(String a){ address = a; }
public int getLength()
{
return this.length;
}
public static byte[] fromArray(ArrayList<BlePacket> m_frag) {
int total_lengh = 0;
for(BlePacket blePacket: m_frag){
total_lengh+=blePacket.getLength();
}
//results
byte[] result = new byte[total_lengh];
//special case for zero
int filled = 0;
for(int i = 0 ; i < m_frag.size(); i++){
byte [] a = m_frag.get(i).getData();
System.arraycopy(a, 0, result, filled, a.length);
filled += a.length;
}
Log.e("BLE PKT: ", "data.length " + result.length);
return result;
}
public static ArrayList<BlePacket> packetsFromBytes(byte[] data){
ArrayList<BlePacket> mPacketList = new ArrayList<>();
boolean hasFragment = true;
int data_length = data.length;
int indx=0;
int m_max_pkt_length = BleDefines.BLE_MAX_DATA_LENGTH-BleDefines.BLE_FRAGMENT_HEADER_LENGTH;
while(hasFragment){
BlePacket blePacket = BlePacket.emptyPacket();
blePacket.setIndx(indx);
if(data_length > m_max_pkt_length){
//more data then it fits to the packet
blePacket.setLast(0);
blePacket.setLength(m_max_pkt_length);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
bos.write(data, indx*m_max_pkt_length, m_max_pkt_length );
blePacket.setData(bos.toByteArray());
indx++;
data_length -=m_max_pkt_length;
} else {
blePacket.setLast(1);
if (data.length > data_length) {
byte[] chunk = new byte[data_length];
System.arraycopy(data, indx*m_max_pkt_length, chunk, 0, data_length);
blePacket.setData(chunk);
} else {
blePacket.setData(data);
}
blePacket.setLength(data_length);
hasFragment = false;
}
mPacketList.add(blePacket);
}
return mPacketList;
}
public static BlePacket packetToNetwork(byte[] data, int indx, int flags)
{
BlePacket blePacket = BlePacket.emptyPacket();
blePacket.indx = indx;
blePacket.length = data.length + BleDefines.BLE_FRAGMENT_HEADER_LENGTH;
blePacket.flags = flags;
blePacket.last = true;
blePacket.data = data;
return blePacket;
}
public static BlePacket packetFromNetworkBytes(byte[] data){
BlePacket blePacket = BlePacket.emptyPacket();
blePacket.setIndx(getIndex(data));
blePacket.setLength(getLength(data));
blePacket.setLast(getFlags(data));
blePacket.setData(data);
return blePacket;
}
private BlePacket() {}
private static BlePacket emptyPacket() {
return new BlePacket();
}
public static byte[] toPacketByteArray(BlePacket blePacket){
Log.d(TAG, "converting to bytes");
int total_pkt_lenght = blePacket.length+3;
byte[] pkt = new byte[blePacket.length+3];
pkt[INDEX] = (byte) blePacket.indx;
pkt[LENGTH] = (byte) blePacket.length;
pkt[FLAGS] = (byte) blePacket.flags;
System.arraycopy( blePacket.getData(), 0, pkt, protocol_offset, blePacket.getData().length );
Log.d(TAG, "Converting pkt to byte[" + pkt.length + "]");
return pkt;
}
//FIXME: this is hardcoded values
private static int getIndex(byte[] data)
{
return ByteWork.convertByteToInt(ByteWork.getBytes(data, INDEX, INDEX+1)[0]);
}
private static int getLength(byte[] data)
{
return ByteWork.convertByteToInt(ByteWork.getBytes(data, LENGTH, LENGTH+1)[0]);
}
private static int getFlags(byte[] data)
{
return ByteWork.convertByteToInt(ByteWork.getBytes(data, FLAGS, FLAGS+1)[0]);
}
private static byte[] getdata(byte[] data)
{
//data is data.length - header 3 bytes
return ByteWork.getBytes(data, protocol_offset, data.length);
}
@Override
public String toString() {
return "BLE PKT[{from: "+this.address+
", indx: " + this.indx+
", length: " + this.length+
", last: " + this.last + "]";
}
} | /**
* Created by lauril on 3/8/17.
*/
public class BlePacket implements CLASS_0 {
private final static int INDEX = 0;
private final static int LENGTH = 1;
private final static int VAR_0 = 2;
private final static int protocol_offset = 3;
//Packet Structure
private int VAR_1=0;
private int length=0;
private int flags = 0;
private byte[] VAR_2;
//addons not serializible to out/in
private CLASS_1 address;
private boolean last = false;
public static final int FLAG_LAST = 1;
public BlePacket(BluetoothGatt VAR_3, BluetoothGattCharacteristic VAR_4){
this(VAR_4.FUNC_0(), VAR_3.getDevice().getAddress());
}
private final static CLASS_1 TAG = BlePacket.class.getSimpleName();
private BlePacket(byte[] VAR_2, CLASS_1 device_address){
this.VAR_1 = getIndex(VAR_2);
this.length = FUNC_1(VAR_2);
this.flags = getFlags(VAR_2);
this.last = (this.flags & FLAG_LAST) == FLAG_LAST;
this.VAR_2 = ByteWork.getBytesSize(VAR_2, protocol_offset, this.length);
this.address = device_address;
}
//This is used to activate notifications
//TODO: needs protocol ID and so on
public BlePacket(byte[] VAR_2){
this.VAR_2 = VAR_2;
}
private void FUNC_2(int VAR_5) {this.VAR_1 = VAR_5 ;}
private void FUNC_4(int l) {this.flags = l; this.last = (FLAG_LAST & this.flags) == FLAG_LAST; }
private void setLength(int l) {this.length = l; }
public void setData(byte[] VAR_5) {this.VAR_2 = VAR_5 ;}
public byte[] getData(){ return VAR_2; }
public CLASS_1 getAddress(){ return address; }
public boolean FUNC_5() {return this.last ; }
public void FUNC_6(CLASS_1 VAR_6){ address = VAR_6; }
public int FUNC_1()
{
return this.length;
}
public static byte[] fromArray(ArrayList<BlePacket> VAR_7) {
int total_lengh = 0;
for(BlePacket VAR_8: VAR_7){
total_lengh+=VAR_8.FUNC_1();
}
//results
byte[] result = new byte[total_lengh];
//special case for zero
int VAR_9 = 0;
for(int VAR_10 = 0 ; VAR_10 < VAR_7.size(); VAR_10++){
byte [] VAR_6 = VAR_7.FUNC_7(VAR_10).getData();
System.FUNC_8(VAR_6, 0, result, VAR_9, VAR_6.length);
VAR_9 += VAR_6.length;
}
Log.e("BLE PKT: ", "data.length " + result.length);
return result;
}
public static ArrayList<BlePacket> packetsFromBytes(byte[] VAR_2){
ArrayList<BlePacket> mPacketList = new ArrayList<>();
boolean VAR_11 = true;
int data_length = VAR_2.length;
int VAR_1=0;
int m_max_pkt_length = VAR_12.VAR_13-VAR_12.VAR_14;
while(VAR_11){
BlePacket VAR_8 = BlePacket.emptyPacket();
VAR_8.FUNC_2(VAR_1);
if(data_length > m_max_pkt_length){
//more data then it fits to the packet
VAR_8.FUNC_4(0);
VAR_8.setLength(m_max_pkt_length);
ByteArrayOutputStream VAR_15 = new ByteArrayOutputStream();
VAR_15.write(VAR_2, VAR_1*m_max_pkt_length, m_max_pkt_length );
VAR_8.setData(VAR_15.FUNC_9());
VAR_1++;
data_length -=m_max_pkt_length;
} else {
VAR_8.FUNC_4(1);
if (VAR_2.length > data_length) {
byte[] chunk = new byte[data_length];
System.FUNC_8(VAR_2, VAR_1*m_max_pkt_length, chunk, 0, data_length);
VAR_8.setData(chunk);
} else {
VAR_8.setData(VAR_2);
}
VAR_8.setLength(data_length);
VAR_11 = false;
}
mPacketList.add(VAR_8);
}
return mPacketList;
}
public static BlePacket FUNC_10(byte[] VAR_2, int VAR_1, int flags)
{
BlePacket VAR_8 = BlePacket.emptyPacket();
VAR_8.VAR_1 = VAR_1;
VAR_8.length = VAR_2.length + VAR_12.VAR_14;
VAR_8.flags = flags;
VAR_8.last = true;
VAR_8.VAR_2 = VAR_2;
return VAR_8;
}
public static BlePacket packetFromNetworkBytes(byte[] VAR_2){
BlePacket VAR_8 = BlePacket.emptyPacket();
VAR_8.FUNC_2(getIndex(VAR_2));
VAR_8.setLength(FUNC_1(VAR_2));
VAR_8.FUNC_4(getFlags(VAR_2));
VAR_8.setData(VAR_2);
return VAR_8;
}
private BlePacket() {}
private static BlePacket emptyPacket() {
return new BlePacket();
}
public static byte[] FUNC_11(BlePacket VAR_8){
Log.FUNC_3(TAG, "converting to bytes");
int total_pkt_lenght = VAR_8.length+3;
byte[] pkt = new byte[VAR_8.length+3];
pkt[INDEX] = (byte) VAR_8.VAR_1;
pkt[LENGTH] = (byte) VAR_8.length;
pkt[VAR_0] = (byte) VAR_8.flags;
System.FUNC_8( VAR_8.getData(), 0, pkt, protocol_offset, VAR_8.getData().length );
Log.FUNC_3(TAG, "Converting pkt to byte[" + pkt.length + "]");
return pkt;
}
//FIXME: this is hardcoded values
private static int getIndex(byte[] VAR_2)
{
return ByteWork.FUNC_12(ByteWork.getBytes(VAR_2, INDEX, INDEX+1)[0]);
}
private static int FUNC_1(byte[] VAR_2)
{
return ByteWork.FUNC_12(ByteWork.getBytes(VAR_2, LENGTH, LENGTH+1)[0]);
}
private static int getFlags(byte[] VAR_2)
{
return ByteWork.FUNC_12(ByteWork.getBytes(VAR_2, VAR_0, VAR_0+1)[0]);
}
private static byte[] getdata(byte[] VAR_2)
{
//data is data.length - header 3 bytes
return ByteWork.getBytes(VAR_2, protocol_offset, VAR_2.length);
}
@Override
public CLASS_1 toString() {
return "BLE PKT[{from: "+this.address+
", indx: " + this.VAR_1+
", length: " + this.length+
", last: " + this.last + "]";
}
} | 0.410345 | {'CLASS_0': 'Serializable', 'VAR_0': 'FLAGS', 'VAR_1': 'indx', 'VAR_2': 'data', 'CLASS_1': 'String', 'VAR_3': 'gatt', 'VAR_4': 'characteristic', 'FUNC_0': 'getValue', 'FUNC_1': 'getLength', 'FUNC_2': 'setIndx', 'VAR_5': 'd', 'FUNC_3': 'd', 'FUNC_4': 'setLast', 'FUNC_5': 'isLast', 'FUNC_6': 'setAddress', 'VAR_6': 'a', 'VAR_7': 'm_frag', 'VAR_8': 'blePacket', 'VAR_9': 'filled', 'VAR_10': 'i', 'FUNC_7': 'get', 'FUNC_8': 'arraycopy', 'VAR_11': 'hasFragment', 'VAR_12': 'BleDefines', 'VAR_13': 'BLE_MAX_DATA_LENGTH', 'VAR_14': 'BLE_FRAGMENT_HEADER_LENGTH', 'VAR_15': 'bos', 'FUNC_9': 'toByteArray', 'FUNC_10': 'packetToNetwork', 'FUNC_11': 'toPacketByteArray', 'FUNC_12': 'convertByteToInt'} | java | OOP | 9.50% |
/**
* Reads the record data for the given record header.
*/
private
byte[] readDataRaw(RandomAccessFile file) throws IOException {
byte[] buf = new byte[this.dataCount];
FileLock lock = file.getChannel()
.lock(this.dataPointer, this.dataCount, true);
file.seek(this.dataPointer);
file.readFully(buf);
lock.release();
return buf;
} | /**
* Reads the record data for the given record header.
*/
private
byte[] FUNC_0(RandomAccessFile file) throws IOException {
byte[] buf = new byte[this.dataCount];
FileLock lock = file.getChannel()
.lock(this.dataPointer, this.dataCount, true);
file.FUNC_1(this.dataPointer);
file.readFully(buf);
lock.release();
return buf;
} | 0.150514 | {'FUNC_0': 'readDataRaw', 'FUNC_1': 'seek'} | java | Procedural | 33.33% |
/**
* Takes a screenshot of the current UI and saves it to the specified file in PNG format. This is only supported
* on clients that return true to the API call {@link #AreScreenshotsSupported AreScreenshotsSupported()}.
* @param FilePath the file path to save the screenshot to (should have a .png file extension)
* @return true if the screenshot was successfully saved to the specified file, false otherwise
* @since 8.0
*
* @declaration public boolean SaveScreenshotToFile(java.io.File FilePath);
*/
public Object runSafely(Catbert.FastStack stack) throws Exception{
UIManager uiMgr = stack.getUIMgr();
java.io.File f = getFile(stack);
if (uiMgr != null && uiMgr.getUIClientType() == UIClient.REMOTE_UI)
{
return ((MiniClientSageRenderer) uiMgr.getRootPanel().getRenderEngine()).saveScreenshotToFile(f) ? Boolean.TRUE : Boolean.FALSE;
}
return Boolean.FALSE;
} | /**
* Takes a screenshot of the current UI and saves it to the specified file in PNG format. This is only supported
* on clients that return true to the API call {@link #AreScreenshotsSupported AreScreenshotsSupported()}.
* @param FilePath the file path to save the screenshot to (should have a .png file extension)
* @return true if the screenshot was successfully saved to the specified file, false otherwise
* @since 8.0
*
* @declaration public boolean SaveScreenshotToFile(java.io.File FilePath);
*/
public Object FUNC_0(Catbert.FastStack stack) throws CLASS_0{
UIManager VAR_0 = stack.FUNC_1();
CLASS_1.io.File f = FUNC_2(stack);
if (VAR_0 != null && VAR_0.FUNC_3() == VAR_1.REMOTE_UI)
{
return ((CLASS_2) VAR_0.FUNC_4().FUNC_5()).FUNC_6(f) ? Boolean.TRUE : Boolean.VAR_2;
}
return Boolean.VAR_2;
} | 0.604856 | {'FUNC_0': 'runSafely', 'CLASS_0': 'Exception', 'VAR_0': 'uiMgr', 'FUNC_1': 'getUIMgr', 'CLASS_1': 'java', 'FUNC_2': 'getFile', 'FUNC_3': 'getUIClientType', 'VAR_1': 'UIClient', 'CLASS_2': 'MiniClientSageRenderer', 'FUNC_4': 'getRootPanel', 'FUNC_5': 'getRenderEngine', 'FUNC_6': 'saveScreenshotToFile', 'VAR_2': 'FALSE'} | java | Texto | 21.68% |
/**
* Created by MomoLuaNative.
* Copyright (c) 2019, Momo Group. All rights reserved.
*
* This source code is licensed under the MIT.
* For the full copyright and license information,please view the LICENSE file in the root directory of this source tree.
*/
package com.immomo.luanative.hotreload;
public class HotReloadServer implements IHotReloadServer {
//
// ---------- 单例
//
private static final HotReloadServer ourInstance = new HotReloadServer();
public static HotReloadServer getInstance() {
return ourInstance;
}
private HotReloadServer() {
}
//
// ---------- 开放接口
//
public void setupUSB(int usbPort) {
}
public void setListener(iHotReloadListener l) {
}
public void start() {
}
public void stop() {
}
public void log(String log) {
}
public void error(String error) {
}
public String getEntryFilePath() {
return null;
}
public String getParams() {
return null;
}
public void startNetClient(String ip, int port) {
}
} | /**
* Created by MomoLuaNative.
* Copyright (c) 2019, Momo Group. All rights reserved.
*
* This source code is licensed under the MIT.
* For the full copyright and license information,please view the LICENSE file in the root directory of this source tree.
*/
package IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3;
public class CLASS_0 implements CLASS_1 {
//
// ---------- 单例
//
private static final CLASS_0 VAR_0 = new CLASS_0();
public static CLASS_0 FUNC_0() {
return VAR_0;
}
private CLASS_0() {
}
//
// ---------- 开放接口
//
public void FUNC_1(int VAR_1) {
}
public void FUNC_2(CLASS_2 VAR_2) {
}
public void FUNC_3() {
}
public void FUNC_4() {
}
public void FUNC_5(String VAR_3) {
}
public void FUNC_6(String VAR_4) {
}
public String getEntryFilePath() {
return null;
}
public String FUNC_7() {
return null;
}
public void FUNC_8(String VAR_5, int port) {
}
} | 0.940889 | {'IMPORT_0': 'com', 'IMPORT_1': 'immomo', 'IMPORT_2': 'luanative', 'IMPORT_3': 'hotreload', 'CLASS_0': 'HotReloadServer', 'CLASS_1': 'IHotReloadServer', 'VAR_0': 'ourInstance', 'FUNC_0': 'getInstance', 'FUNC_1': 'setupUSB', 'VAR_1': 'usbPort', 'FUNC_2': 'setListener', 'CLASS_2': 'iHotReloadListener', 'VAR_2': 'l', 'FUNC_3': 'start', 'FUNC_4': 'stop', 'FUNC_5': 'log', 'VAR_3': 'log', 'FUNC_6': 'error', 'VAR_4': 'error', 'FUNC_7': 'getParams', 'FUNC_8': 'startNetClient', 'VAR_5': 'ip'} | java | Hibrido | 100.00% |
package com.rohan.testing.basic.business;
import org.json.JSONException;
import org.junit.jupiter.api.Test;
import org.skyscreamer.jsonassert.JSONAssert;
public class JsonAssertTest {
String actualResponse = "{\"id\":1,\"name\":\"Ball\",\"price\":10,\"quantity\":100}";
@Test
public void jsonAssert_StrictTrue_ExactMatchExceptForSpaces() throws JSONException {
String expectedResponse = "{\"id\":1,\"name\":\"Ball\",\"price\":10,\"quantity\":100}";
// strict = true, matches exact structure, spaces doesn't matters
JSONAssert.assertEquals(expectedResponse, actualResponse, true);
}
@Test
public void jsonAssert_StrictFalse() throws JSONException {
String expectedResponse = "{\"id\":1,\"name\":\"Ball\"}";
// strict = true, matches exact structure, spaces doesn't matters
JSONAssert.assertEquals(expectedResponse, actualResponse, false);
}
@Test
public void jsonAssert_StrictFalse_WillFail() throws JSONException {
String expectedResponse = "{\"id\":1,\"name\":\"Bat\"}";
// strict = true, matches exact structure, spaces doesn't matters
JSONAssert.assertNotEquals(expectedResponse, actualResponse, false);
}
@Test
public void jsonAssert_StrictFalse_WithoutEscapeCharacters() throws JSONException {
// Only escape if you have spaces in your values
String expectedResponse = "{id:1, name:Ball}";
JSONAssert.assertEquals(expectedResponse, actualResponse, false);
}
}
| package IMPORT_0.rohan.testing.IMPORT_1.business;
import org.json.JSONException;
import org.IMPORT_2.jupiter.IMPORT_3.IMPORT_4;
import org.skyscreamer.jsonassert.IMPORT_5;
public class CLASS_0 {
CLASS_1 actualResponse = "{\"id\":1,\"name\":\"Ball\",\"price\":10,\"quantity\":100}";
@IMPORT_4
public void FUNC_0() throws JSONException {
CLASS_1 VAR_0 = "{\"id\":1,\"name\":\"Ball\",\"price\":10,\"quantity\":100}";
// strict = true, matches exact structure, spaces doesn't matters
IMPORT_5.FUNC_1(VAR_0, actualResponse, true);
}
@IMPORT_4
public void FUNC_2() throws JSONException {
CLASS_1 VAR_0 = "{\"id\":1,\"name\":\"Ball\"}";
// strict = true, matches exact structure, spaces doesn't matters
IMPORT_5.FUNC_1(VAR_0, actualResponse, false);
}
@IMPORT_4
public void FUNC_3() throws JSONException {
CLASS_1 VAR_0 = "{\"id\":1,\"name\":\"Bat\"}";
// strict = true, matches exact structure, spaces doesn't matters
IMPORT_5.assertNotEquals(VAR_0, actualResponse, false);
}
@IMPORT_4
public void FUNC_4() throws JSONException {
// Only escape if you have spaces in your values
CLASS_1 VAR_0 = "{id:1, name:Ball}";
IMPORT_5.FUNC_1(VAR_0, actualResponse, false);
}
}
| 0.4588 | {'IMPORT_0': 'com', 'IMPORT_1': 'basic', 'IMPORT_2': 'junit', 'IMPORT_3': 'api', 'IMPORT_4': 'Test', 'IMPORT_5': 'JSONAssert', 'CLASS_0': 'JsonAssertTest', 'CLASS_1': 'String', 'FUNC_0': 'jsonAssert_StrictTrue_ExactMatchExceptForSpaces', 'VAR_0': 'expectedResponse', 'FUNC_1': 'assertEquals', 'FUNC_2': 'jsonAssert_StrictFalse', 'FUNC_3': 'jsonAssert_StrictFalse_WillFail', 'FUNC_4': 'jsonAssert_StrictFalse_WithoutEscapeCharacters'} | java | OOP | 100.00% |
package net.icelane.massband;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
import net.icelane.massband.config.configs.Config;
import net.icelane.massband.core.Massband;
public class Plugin extends JavaPlugin{
private static Plugin plugin;
protected static Logger logger;
private boolean permissionsEnabled = true;
public static Plugin get(){
return plugin;
}
public static FileConfiguration config(){
return get().getConfig();
}
@Override
public void onLoad() {
super.onLoad();
plugin = this;
logger = this.getLogger();
}
@Override
public void onEnable() {
super.onEnable();
Config.initialize();
Config.get().load();
Config.get().save();
Server.registerEvents();
Server.registerCommands();
if (Config.get().cleanup_Enabled.get())
Massband.removeAllMarkers(null);
}
@Override
public void onDisable() {
super.onDisable();
Massband.cleanAll();
}
public void disable(){
Bukkit.getPluginManager().disablePlugin(this);
}
public boolean isPermissionsEnabled() {
return permissionsEnabled;
}
public void setPermissionsEnabled(boolean usePermissions) {
this.permissionsEnabled = usePermissions;
}
}
| package IMPORT_0.IMPORT_1.IMPORT_2;
import IMPORT_3.IMPORT_4.IMPORT_5.IMPORT_6;
import IMPORT_7.IMPORT_8.IMPORT_9;
import IMPORT_7.IMPORT_8.IMPORT_10.IMPORT_11.IMPORT_12;
import IMPORT_7.IMPORT_8.IMPORT_13.IMPORT_3.IMPORT_14;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_15.IMPORT_16.IMPORT_17;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_18.IMPORT_19;
public class CLASS_0 extends IMPORT_14{
private static CLASS_0 IMPORT_13;
protected static IMPORT_6 VAR_0;
private boolean VAR_1 = true;
public static CLASS_0 FUNC_0(){
return IMPORT_13;
}
public static IMPORT_12 IMPORT_15(){
return FUNC_0().FUNC_1();
}
@VAR_2
public void FUNC_2() {
super.FUNC_2();
IMPORT_13 = this;
VAR_0 = this.FUNC_3();
}
@VAR_2
public void FUNC_4() {
super.FUNC_4();
IMPORT_17.FUNC_5();
IMPORT_17.FUNC_0().FUNC_6();
IMPORT_17.FUNC_0().FUNC_7();
VAR_3.registerEvents();
VAR_3.FUNC_8();
if (IMPORT_17.FUNC_0().VAR_4.FUNC_0())
IMPORT_19.FUNC_9(null);
}
@VAR_2
public void FUNC_10() {
super.FUNC_10();
IMPORT_19.FUNC_11();
}
public void FUNC_12(){
IMPORT_9.FUNC_13().FUNC_14(this);
}
public boolean FUNC_15() {
return VAR_1;
}
public void FUNC_16(boolean VAR_5) {
this.VAR_1 = VAR_5;
}
}
| 0.909526 | {'IMPORT_0': 'net', 'IMPORT_1': 'icelane', 'IMPORT_2': 'massband', 'IMPORT_3': 'java', 'IMPORT_4': 'util', 'IMPORT_5': 'logging', 'IMPORT_6': 'Logger', 'IMPORT_7': 'org', 'IMPORT_8': 'bukkit', 'IMPORT_9': 'Bukkit', 'IMPORT_10': 'configuration', 'IMPORT_11': 'file', 'IMPORT_12': 'FileConfiguration', 'IMPORT_13': 'plugin', 'IMPORT_14': 'JavaPlugin', 'IMPORT_15': 'config', 'IMPORT_16': 'configs', 'IMPORT_17': 'Config', 'IMPORT_18': 'core', 'IMPORT_19': 'Massband', 'CLASS_0': 'Plugin', 'VAR_0': 'logger', 'VAR_1': 'permissionsEnabled', 'FUNC_0': 'get', 'FUNC_1': 'getConfig', 'VAR_2': 'Override', 'FUNC_2': 'onLoad', 'FUNC_3': 'getLogger', 'FUNC_4': 'onEnable', 'FUNC_5': 'initialize', 'FUNC_6': 'load', 'FUNC_7': 'save', 'VAR_3': 'Server', 'FUNC_8': 'registerCommands', 'VAR_4': 'cleanup_Enabled', 'FUNC_9': 'removeAllMarkers', 'FUNC_10': 'onDisable', 'FUNC_11': 'cleanAll', 'FUNC_12': 'disable', 'FUNC_13': 'getPluginManager', 'FUNC_14': 'disablePlugin', 'FUNC_15': 'isPermissionsEnabled', 'FUNC_16': 'setPermissionsEnabled', 'VAR_5': 'usePermissions'} | java | OOP | 68.60% |
/**
* Runs a test for concurrent database creations.
* @throws IOException I/O exception
*/
@Test
public void createTest() throws IOException {
sess.execute(new DropDB(NAME));
sess.execute(new CreateDB(NAME, FILE));
} | /**
* Runs a test for concurrent database creations.
* @throws IOException I/O exception
*/
@Test
public void FUNC_0() throws CLASS_0 {
VAR_0.execute(new DropDB(NAME));
VAR_0.execute(new CreateDB(NAME, FILE));
} | 0.496279 | {'FUNC_0': 'createTest', 'CLASS_0': 'IOException', 'VAR_0': 'sess'} | java | Procedural | 51.22% |
package it.marbat.pdfjet.lib;
/**
* Used to specify the segment of Ellipse or Circle to draw.
* See Example_18
*/
@SuppressWarnings("unused")
public class Segment {
public static final int CLOCKWISE_00_03 = 0;
public static final int CLOCKWISE_03_06 = 1;
public static final int CLOCKWISE_06_09 = 2;
public static final int CLOCKWISE_09_12 = 3;
}
| package it.IMPORT_0.IMPORT_1.IMPORT_2;
/**
* Used to specify the segment of Ellipse or Circle to draw.
* See Example_18
*/
@VAR_0("unused")
public class CLASS_0 {
public static final int VAR_1 = 0;
public static final int CLOCKWISE_03_06 = 1;
public static final int VAR_2 = 2;
public static final int VAR_3 = 3;
}
| 0.687992 | {'IMPORT_0': 'marbat', 'IMPORT_1': 'pdfjet', 'IMPORT_2': 'lib', 'VAR_0': 'SuppressWarnings', 'CLASS_0': 'Segment', 'VAR_1': 'CLOCKWISE_00_03', 'VAR_2': 'CLOCKWISE_06_09', 'VAR_3': 'CLOCKWISE_09_12'} | java | Hibrido | 100.00% |
/**
* Removes heavyweight parts of the Notification object for archival or for sending to
* listeners when the full contents are not necessary.
* @hide
*/
public final void lightenPayload() {
tickerView = null;
contentView = null;
bigContentView = null;
headsUpContentView = null;
mLargeIcon = null;
if (extras != null && !extras.isEmpty()) {
final Set<String> keyset = extras.keySet();
final int N = keyset.size();
final String[] keys = keyset.toArray(new String[N]);
for (int i=0; i<N; i++) {
final String key = keys[i];
final Object obj = extras.get(key);
if (obj != null &&
( obj instanceof Parcelable
|| obj instanceof Parcelable[]
|| obj instanceof SparseArray
|| obj instanceof ArrayList)) {
extras.remove(key);
}
}
}
} | /**
* Removes heavyweight parts of the Notification object for archival or for sending to
* listeners when the full contents are not necessary.
* @hide
*/
public final void FUNC_0() {
tickerView = null;
VAR_0 = null;
bigContentView = null;
headsUpContentView = null;
mLargeIcon = null;
if (extras != null && !extras.FUNC_1()) {
final Set<String> keyset = extras.keySet();
final int N = keyset.size();
final String[] keys = keyset.toArray(new String[N]);
for (int VAR_1=0; VAR_1<N; VAR_1++) {
final String key = keys[VAR_1];
final Object obj = extras.FUNC_2(key);
if (obj != null &&
( obj instanceof Parcelable
|| obj instanceof Parcelable[]
|| obj instanceof CLASS_0
|| obj instanceof ArrayList)) {
extras.FUNC_3(key);
}
}
}
} | 0.320246 | {'FUNC_0': 'lightenPayload', 'VAR_0': 'contentView', 'FUNC_1': 'isEmpty', 'VAR_1': 'i', 'FUNC_2': 'get', 'CLASS_0': 'SparseArray', 'FUNC_3': 'remove'} | java | Procedural | 36.80% |
/**
* @author Ravi Mohan
* @author Ciaran O'Reilly
* @author Ruediger Lunde
*/
public class NQueensFunctionsTest {
private Function<NQueensBoard, List<QueenAction>> actionsFn;
private BiFunction<NQueensBoard, QueenAction, NQueensBoard> resultFn;
private Predicate<NQueensBoard> goalTest;
private NQueensBoard oneBoard;
private NQueensBoard eightBoard;
private NQueensBoard board;
@Before
public void setUp() {
oneBoard = new NQueensBoard(1);
eightBoard = new NQueensBoard(8);
board = new NQueensBoard(8);
actionsFn = NQueensFunctions::getIFActions;
resultFn = NQueensFunctions::getResult;
goalTest = NQueensFunctions::testGoal;
}
@Test
public void testSimpleBoardSuccessorGenerator() {
List<QueenAction> actions = new ArrayList<>(actionsFn.apply(oneBoard));
Assert.assertEquals(1, actions.size());
NQueensBoard next = resultFn.apply(oneBoard, actions.get(0));
Assert.assertEquals(1, next.getNumberOfQueensOnBoard());
}
@Test
public void testComplexBoardSuccessorGenerator() {
List<QueenAction> actions = new ArrayList<>(actionsFn.apply(eightBoard));
Assert.assertEquals(8, actions.size());
NQueensBoard next = resultFn.apply(eightBoard, actions.get(0));
Assert.assertEquals(1, next.getNumberOfQueensOnBoard());
actions = new ArrayList<>(actionsFn.apply(next));
Assert.assertEquals(6, actions.size());
}
@Test
public void testEmptyBoard() {
Assert.assertFalse(goalTest.test(board));
}
@Test
public void testSingleSquareBoard() {
board = new NQueensBoard(1);
Assert.assertFalse(goalTest.test(board));
board.addQueenAt(new XYLocation(0, 0));
Assert.assertTrue(goalTest.test(board));
}
@Test
public void testInCorrectPlacement() {
Assert.assertFalse(goalTest.test(board));
// This is the configuration of Figure 3.5 (b) in AIMA 2nd Edition
board.addQueenAt(new XYLocation(0, 0));
board.addQueenAt(new XYLocation(1, 2));
board.addQueenAt(new XYLocation(2, 4));
board.addQueenAt(new XYLocation(3, 6));
board.addQueenAt(new XYLocation(4, 1));
board.addQueenAt(new XYLocation(5, 3));
board.addQueenAt(new XYLocation(6, 5));
board.addQueenAt(new XYLocation(7, 7));
Assert.assertFalse(goalTest.test(board));
}
@Test
public void testCorrectPlacement() {
Assert.assertFalse(goalTest.test(board));
// This is the configuration of Figure 5.9 (c) in AIMA 2nd Edition
board.addQueenAt(new XYLocation(0, 1));
board.addQueenAt(new XYLocation(1, 4));
board.addQueenAt(new XYLocation(2, 6));
board.addQueenAt(new XYLocation(3, 3));
board.addQueenAt(new XYLocation(4, 0));
board.addQueenAt(new XYLocation(5, 7));
board.addQueenAt(new XYLocation(6, 5));
board.addQueenAt(new XYLocation(7, 2));
Assert.assertTrue(goalTest.test(board));
}
} | /**
* @author Ravi Mohan
* @author Ciaran O'Reilly
* @author Ruediger Lunde
*/
public class CLASS_0 {
private CLASS_1<CLASS_2, CLASS_3<CLASS_4>> VAR_0;
private CLASS_5<CLASS_2, CLASS_4, CLASS_2> VAR_1;
private CLASS_6<CLASS_2> VAR_2;
private CLASS_2 VAR_3;
private CLASS_2 VAR_4;
private CLASS_2 VAR_5;
@Before
public void FUNC_0() {
VAR_3 = new CLASS_2(1);
VAR_4 = new CLASS_2(8);
VAR_5 = new CLASS_2(8);
VAR_0 = VAR_6::VAR_7;
VAR_1 = VAR_6::VAR_8;
VAR_2 = VAR_6::VAR_9;
}
@VAR_10
public void FUNC_1() {
CLASS_3<CLASS_4> VAR_11 = new CLASS_7<>(VAR_0.FUNC_2(VAR_3));
VAR_12.FUNC_3(1, VAR_11.FUNC_4());
CLASS_2 VAR_13 = VAR_1.FUNC_2(VAR_3, VAR_11.FUNC_5(0));
VAR_12.FUNC_3(1, VAR_13.FUNC_6());
}
@VAR_10
public void FUNC_7() {
CLASS_3<CLASS_4> VAR_11 = new CLASS_7<>(VAR_0.FUNC_2(VAR_4));
VAR_12.FUNC_3(8, VAR_11.FUNC_4());
CLASS_2 VAR_13 = VAR_1.FUNC_2(VAR_4, VAR_11.FUNC_5(0));
VAR_12.FUNC_3(1, VAR_13.FUNC_6());
VAR_11 = new CLASS_7<>(VAR_0.FUNC_2(VAR_13));
VAR_12.FUNC_3(6, VAR_11.FUNC_4());
}
@VAR_10
public void FUNC_8() {
VAR_12.FUNC_9(VAR_2.FUNC_10(VAR_5));
}
@VAR_10
public void FUNC_11() {
VAR_5 = new CLASS_2(1);
VAR_12.FUNC_9(VAR_2.FUNC_10(VAR_5));
VAR_5.FUNC_12(new CLASS_8(0, 0));
VAR_12.FUNC_13(VAR_2.FUNC_10(VAR_5));
}
@VAR_10
public void FUNC_14() {
VAR_12.FUNC_9(VAR_2.FUNC_10(VAR_5));
// This is the configuration of Figure 3.5 (b) in AIMA 2nd Edition
VAR_5.FUNC_12(new CLASS_8(0, 0));
VAR_5.FUNC_12(new CLASS_8(1, 2));
VAR_5.FUNC_12(new CLASS_8(2, 4));
VAR_5.FUNC_12(new CLASS_8(3, 6));
VAR_5.FUNC_12(new CLASS_8(4, 1));
VAR_5.FUNC_12(new CLASS_8(5, 3));
VAR_5.FUNC_12(new CLASS_8(6, 5));
VAR_5.FUNC_12(new CLASS_8(7, 7));
VAR_12.FUNC_9(VAR_2.FUNC_10(VAR_5));
}
@VAR_10
public void FUNC_15() {
VAR_12.FUNC_9(VAR_2.FUNC_10(VAR_5));
// This is the configuration of Figure 5.9 (c) in AIMA 2nd Edition
VAR_5.FUNC_12(new CLASS_8(0, 1));
VAR_5.FUNC_12(new CLASS_8(1, 4));
VAR_5.FUNC_12(new CLASS_8(2, 6));
VAR_5.FUNC_12(new CLASS_8(3, 3));
VAR_5.FUNC_12(new CLASS_8(4, 0));
VAR_5.FUNC_12(new CLASS_8(5, 7));
VAR_5.FUNC_12(new CLASS_8(6, 5));
VAR_5.FUNC_12(new CLASS_8(7, 2));
VAR_12.FUNC_13(VAR_2.FUNC_10(VAR_5));
}
} | 0.925722 | {'CLASS_0': 'NQueensFunctionsTest', 'CLASS_1': 'Function', 'CLASS_2': 'NQueensBoard', 'CLASS_3': 'List', 'CLASS_4': 'QueenAction', 'VAR_0': 'actionsFn', 'CLASS_5': 'BiFunction', 'VAR_1': 'resultFn', 'CLASS_6': 'Predicate', 'VAR_2': 'goalTest', 'VAR_3': 'oneBoard', 'VAR_4': 'eightBoard', 'VAR_5': 'board', 'FUNC_0': 'setUp', 'VAR_6': 'NQueensFunctions', 'VAR_7': 'getIFActions', 'VAR_8': 'getResult', 'VAR_9': 'testGoal', 'VAR_10': 'Test', 'FUNC_1': 'testSimpleBoardSuccessorGenerator', 'VAR_11': 'actions', 'CLASS_7': 'ArrayList', 'FUNC_2': 'apply', 'VAR_12': 'Assert', 'FUNC_3': 'assertEquals', 'FUNC_4': 'size', 'VAR_13': 'next', 'FUNC_5': 'get', 'FUNC_6': 'getNumberOfQueensOnBoard', 'FUNC_7': 'testComplexBoardSuccessorGenerator', 'FUNC_8': 'testEmptyBoard', 'FUNC_9': 'assertFalse', 'FUNC_10': 'test', 'FUNC_11': 'testSingleSquareBoard', 'FUNC_12': 'addQueenAt', 'CLASS_8': 'XYLocation', 'FUNC_13': 'assertTrue', 'FUNC_14': 'testInCorrectPlacement', 'FUNC_15': 'testCorrectPlacement'} | java | OOP | 19.51% |
package jdbc.batch;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
*
* @author ivan.yuriev
*/
public class CallStoredProcedure extends BatchExecutor {
private static final Logger LOG = LogManager.getLogger(CallStoredProcedure.class);
private static final int BATCH_SIZE = 50;
private static final String TABLE_NAME = "book";
private static final String PROCEDURE_NAME = "insert_book";
private static final String COMMAND = "call insert_book(?)";
private static final String DROP_TABLE = "DROP table if exists book";
private static final String CREATE_TABLE = "create table book ( "
+ " id bigserial not null, "
+ " title varchar(50), "
+ " primary key (id) "
+ ")";
private static final String CREATE_PROCEDURE = "CREATE PROCEDURE insert_book(bookTitle varchar(50)) "
+ "AS $$ "
+ "BEGIN "
+ " INSERT INTO book(title) "
+ " SELECT bookTitle "
+ " WHERE NOT EXISTS ( "
+ " SELECT 1 FROM book WHERE title=bookTitle "
+ " ); "
+ "END ; "
+ "$$ "
+ "LANGUAGE plpgsql;";
public CallStoredProcedure() {
super(LOG);
prepareAll();
}
private void prepareAll(){
Set<String> procedureNames = getProcedureNames();
Set<String> tableNames = getTableNames();
if (!procedureNames.contains(PROCEDURE_NAME)) createProcedure();
if (!tableNames.contains(TABLE_NAME)) createTable();
}
public void runStoredProcedure(List<Book> books) {
if (books == null || books.isEmpty()) return;
try (Connection connection = DbConnection.getConnection()) {
connection.setAutoCommit(false);
try (CallableStatement cstmt = connection.prepareCall(COMMAND)) {
for (int i = 0; i < books.size(); i++) {
getBatchUpdateLog().add(String.join(" ", "Query:", COMMAND, "title:", books.get(i).getTitle()));
cstmt.setString(1, books.get(i).getTitle());
cstmt.addBatch();
if (((i + 1) % BATCH_SIZE == 0) || (i == (books.size() - 1))) {
executeBatch(connection, cstmt);
}
}
}
} catch (SQLException ex) {
LOG.error(ex);
} finally {
getBatchUpdateLog().clear();
}
}
private Set<String> getProcedureNames() {
Set<String> result = new HashSet<>();
try (Connection connection = DbConnection.getConnection()) {
DatabaseMetaData meta = connection.getMetaData();
try (ResultSet res = meta.getProcedures(null, null, null)) {
while (res.next()) {
result.add(res.getString("PROCEDURE_NAME"));
}
}
} catch (SQLException ex) {
LOG.error(ex);
}
return result;
}
private Set<String> getTableNames() {
Set<String> result = new HashSet<>();
try (Connection connection = DbConnection.getConnection()) {
DatabaseMetaData meta = connection.getMetaData();
try (ResultSet res = meta.getTables(null, null, "%", null)) {
while (res.next()) {
result.add(res.getString("TABLE_NAME"));
}
}
} catch (SQLException ex) {
LOG.error(ex);
}
return result;
}
public void dropTable() {
executeQuery(DROP_TABLE);
}
public void createTable() {
executeQuery(CREATE_TABLE);
}
public void createProcedure() {
executeQuery(CREATE_PROCEDURE);
}
private void executeQuery(String query) {
try (Connection connection = DbConnection.getConnection()) {
try (Statement stmt = connection.createStatement()) {
stmt.executeQuery(query);
}
} catch (SQLException ex) {
LOG.error(ex);
}
}
}
| package IMPORT_0.batch;
import IMPORT_1.sql.CallableStatement;
import IMPORT_1.sql.Connection;
import IMPORT_1.sql.DatabaseMetaData;
import IMPORT_1.sql.ResultSet;
import IMPORT_1.sql.SQLException;
import IMPORT_1.sql.Statement;
import IMPORT_1.util.HashSet;
import IMPORT_1.util.List;
import IMPORT_1.util.IMPORT_2;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
*
* @author ivan.yuriev
*/
public class CallStoredProcedure extends BatchExecutor {
private static final Logger VAR_0 = LogManager.getLogger(CallStoredProcedure.class);
private static final int BATCH_SIZE = 50;
private static final String TABLE_NAME = "book";
private static final String PROCEDURE_NAME = "insert_book";
private static final String COMMAND = "call insert_book(?)";
private static final String VAR_1 = "DROP table if exists book";
private static final String CREATE_TABLE = "create table book ( "
+ " id bigserial not null, "
+ " title varchar(50), "
+ " primary key (id) "
+ ")";
private static final String CREATE_PROCEDURE = "CREATE PROCEDURE insert_book(bookTitle varchar(50)) "
+ "AS $$ "
+ "BEGIN "
+ " INSERT INTO book(title) "
+ " SELECT bookTitle "
+ " WHERE NOT EXISTS ( "
+ " SELECT 1 FROM book WHERE title=bookTitle "
+ " ); "
+ "END ; "
+ "$$ "
+ "LANGUAGE plpgsql;";
public CallStoredProcedure() {
super(VAR_0);
prepareAll();
}
private void prepareAll(){
IMPORT_2<String> procedureNames = getProcedureNames();
IMPORT_2<String> tableNames = FUNC_0();
if (!procedureNames.contains(PROCEDURE_NAME)) FUNC_1();
if (!tableNames.contains(TABLE_NAME)) createTable();
}
public void FUNC_2(List<Book> books) {
if (books == null || books.isEmpty()) return;
try (Connection VAR_2 = DbConnection.getConnection()) {
VAR_2.setAutoCommit(false);
try (CallableStatement cstmt = VAR_2.prepareCall(COMMAND)) {
for (int i = 0; i < books.size(); i++) {
getBatchUpdateLog().FUNC_3(String.join(" ", "Query:", COMMAND, "title:", books.get(i).getTitle()));
cstmt.FUNC_4(1, books.get(i).getTitle());
cstmt.addBatch();
if (((i + 1) % BATCH_SIZE == 0) || (i == (books.size() - 1))) {
executeBatch(VAR_2, cstmt);
}
}
}
} catch (SQLException ex) {
VAR_0.FUNC_5(ex);
} finally {
getBatchUpdateLog().clear();
}
}
private IMPORT_2<String> getProcedureNames() {
IMPORT_2<String> result = new HashSet<>();
try (Connection VAR_2 = DbConnection.getConnection()) {
DatabaseMetaData meta = VAR_2.getMetaData();
try (ResultSet res = meta.getProcedures(null, null, null)) {
while (res.next()) {
result.FUNC_3(res.getString("PROCEDURE_NAME"));
}
}
} catch (SQLException ex) {
VAR_0.FUNC_5(ex);
}
return result;
}
private IMPORT_2<String> FUNC_0() {
IMPORT_2<String> result = new HashSet<>();
try (Connection VAR_2 = DbConnection.getConnection()) {
DatabaseMetaData meta = VAR_2.getMetaData();
try (ResultSet res = meta.getTables(null, null, "%", null)) {
while (res.next()) {
result.FUNC_3(res.getString("TABLE_NAME"));
}
}
} catch (SQLException ex) {
VAR_0.FUNC_5(ex);
}
return result;
}
public void dropTable() {
FUNC_6(VAR_1);
}
public void createTable() {
FUNC_6(CREATE_TABLE);
}
public void FUNC_1() {
FUNC_6(CREATE_PROCEDURE);
}
private void FUNC_6(String query) {
try (Connection VAR_2 = DbConnection.getConnection()) {
try (Statement stmt = VAR_2.createStatement()) {
stmt.FUNC_6(query);
}
} catch (SQLException ex) {
VAR_0.FUNC_5(ex);
}
}
}
| 0.150933 | {'IMPORT_0': 'jdbc', 'IMPORT_1': 'java', 'IMPORT_2': 'Set', 'VAR_0': 'LOG', 'VAR_1': 'DROP_TABLE', 'FUNC_0': 'getTableNames', 'FUNC_1': 'createProcedure', 'FUNC_2': 'runStoredProcedure', 'VAR_2': 'connection', 'FUNC_3': 'add', 'FUNC_4': 'setString', 'FUNC_5': 'error', 'FUNC_6': 'executeQuery'} | java | error | 0 |
/*
* Copyright (c) 2012-2019 Snowflake Computing Inc. All rights reserved.
*/
package net.snowflake.client.jdbc.telemetry;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import net.snowflake.client.core.HttpUtil;
import net.snowflake.client.core.OCSPMode;
import net.snowflake.client.core.ObjectMapperFactory;
import net.snowflake.client.core.SFSession;
import net.snowflake.client.jdbc.SnowflakeConnectionV1;
import net.snowflake.client.jdbc.SnowflakeSQLException;
import net.snowflake.client.log.SFLogger;
import net.snowflake.client.log.SFLoggerFactory;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import java.io.IOException;
import java.rmi.UnexpectedException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.LinkedList;
/**
* Copyright (c) 2018-2019 Snowflake Computing Inc. All rights reserved.
* <p>
* Telemetry Service Interface
*/
public class TelemetryClient implements Telemetry
{
private static final SFLogger logger =
SFLoggerFactory.getLogger(SFSession.class);
private static final String SF_PATH_TELEMETRY = "/telemetry/send";
// if the number of cached logs is larger than this threshold,
// the telemetry connector will flush the buffer automatically.
private final int forceFlushSize;
private static final int DEFAULT_FORCE_FLUSH_SIZE = 100;
private final String serverUrl;
private final String telemetryUrl;
private final SFSession session;
private LinkedList<TelemetryData> logBatch;
private static final ObjectMapper mapper =
ObjectMapperFactory.getObjectMapper();
private boolean isClosed;
private Object locker = new Object();
//false if meet any error when sending metrics
private boolean isTelemetryServiceAvailable = true;
private TelemetryClient(SFSession session, int flushSize)
{
this.session = session;
this.serverUrl = session.getUrl();
if (this.serverUrl.endsWith("/"))
{
this.telemetryUrl =
this.serverUrl.substring(0, this.serverUrl.length() - 1)
+ SF_PATH_TELEMETRY;
}
else
{
this.telemetryUrl = this.serverUrl + SF_PATH_TELEMETRY;
}
this.logBatch = new LinkedList<>();
this.isClosed = false;
this.forceFlushSize = flushSize;
}
/**
* Return whether the client can be used to add/send metrics
*
* @return whether client is enabled
*/
public boolean isTelemetryEnabled()
{
return this.session.isClientTelemetryEnabled() && this.isTelemetryServiceAvailable;
}
/**
* Disable any use of the client to add/send metrics
*/
public void disableTelemetry()
{
this.isTelemetryServiceAvailable = false;
}
/**
* Initialize the telemetry connector
*
* @param conn connection with the session to use for the connector
* @param flushSize maximum size of telemetry batch before flush
* @return a telemetry connector
*/
public static Telemetry createTelemetry(Connection conn, int flushSize)
{
try
{
return createTelemetry(conn.unwrap(SnowflakeConnectionV1.class).getSfSession(), flushSize);
}
catch (SQLException ex)
{
logger.debug("input connection is not a SnowflakeConnection");
return null;
}
}
/**
* Initialize the telemetry connector
*
* @param conn connection with the session to use for the connector
* @return a telemetry connector
*/
public static Telemetry createTelemetry(Connection conn)
{
return createTelemetry(conn, DEFAULT_FORCE_FLUSH_SIZE);
}
/**
* Initialize the telemetry connector
*
* @param session session to use for telemetry dumps
* @return a telemetry connector
*/
public static Telemetry createTelemetry(SFSession session)
{
return createTelemetry(session, DEFAULT_FORCE_FLUSH_SIZE);
}
/**
* Initialize the telemetry connector
*
* @param session session to use for telemetry dumps
* @param flushSize maximum size of telemetry batch before flush
* @return a telemetry connector
*/
public static Telemetry createTelemetry(SFSession session, int flushSize)
{
return new TelemetryClient(session, flushSize);
}
/**
* Add log to batch to be submitted to telemetry. Send batch if forceFlushSize
* reached
*
* @param log entry to add
* @throws IOException if closed or uploading batch fails
*/
@Override
public void addLogToBatch(TelemetryData log) throws IOException
{
if (isClosed)
{
throw new IOException("Telemetry connector is closed");
}
if (!isTelemetryEnabled())
{
return; // if disable, do nothing
}
synchronized (locker)
{
this.logBatch.add(log);
}
if (this.logBatch.size() >= this.forceFlushSize)
{
this.sendBatch();
}
}
/**
* Add log to batch to be submitted to telemetry. Send batch if forceFlushSize
* reached
*
* @param message json node of log
* @param timeStamp timestamp to use for log
* @throws IOException if closed or uploading batch fails
*/
public void addLogToBatch(ObjectNode message, long timeStamp) throws
IOException
{
this.addLogToBatch(new TelemetryData(message, timeStamp));
}
/**
* Attempt to add log to batch, and suppress exceptions thrown in case of
* failure
*
* @param log entry to add
*/
@Override
public void tryAddLogToBatch(TelemetryData log)
{
try
{
addLogToBatch(log);
}
catch (IOException ex)
{
logger.debug("Exception encountered while sending metrics to telemetry endpoint.", ex);
}
}
/**
* Close telemetry connector and send any unsubmitted logs
*
* @throws IOException if closed or uploading batch fails
*/
@Override
public void close() throws IOException
{
if (isClosed)
{
throw new IOException("Telemetry connector is closed");
}
try
{
this.sendBatch();
}
catch (IOException e)
{
logger.error("Send logs failed on closing", e);
}
finally
{
this.isClosed = true;
}
}
/**
* Return whether the client has been closed
*
* @return whether client is closed
*/
public boolean isClosed()
{
return this.isClosed;
}
/**
* Send all cached logs to server
*
* @return whether the logs were sent successfully
* @throws IOException if closed or uploading batch fails
*/
@Override
public boolean sendBatch() throws IOException
{
if (isClosed)
{
throw new IOException("Telemetry connector is closed");
}
if (!isTelemetryEnabled())
{
return false;
}
LinkedList<TelemetryData> tmpList;
synchronized (locker)
{
tmpList = this.logBatch;
this.logBatch = new LinkedList<>();
}
if (session.isClosed())
{
throw new UnexpectedException("Session is closed when sending log");
}
if (!tmpList.isEmpty())
{
//session shared with JDBC
String sessionToken = this.session.getSessionToken();
HttpPost post = new HttpPost(this.telemetryUrl);
post.setEntity(new StringEntity(logsToString(tmpList)));
post.setHeader("Content-type", "application/json");
post.setHeader("Authorization", "Snowflake Token=\"" + sessionToken +
"\"");
String response = null;
try
{
response = HttpUtil.executeGeneralRequest(post, 1000, OCSPMode.FAIL_OPEN);
}
catch (SnowflakeSQLException e)
{
disableTelemetry(); // when got error like 404 or bad request, disable telemetry in this telemetry instance
logger.error(
"Telemetry request failed, " +
"response: {}, exception: {}", response, e.getMessage());
return false;
}
}
return true;
}
/**
* Send a log to the server, along with any existing logs waiting to be sent
*
* @param log entry to send
* @return whether the logs were sent successfully
* @throws IOException if closed or uploading batch fails
*/
public boolean sendLog(TelemetryData log) throws IOException
{
addLogToBatch(log);
return sendBatch();
}
/**
* Send a log to the server, along with any existing logs waiting to be sent
*
* @param message json node of log
* @param timeStamp timestamp to use for log
* @return whether the logs were sent successfully
* @throws IOException if closed or uploading batch fails
*/
public boolean sendLog(ObjectNode message, long timeStamp) throws IOException
{
return this.sendLog(new TelemetryData(message, timeStamp));
}
/**
* convert a list of log to a JSON object
*
* @param telemetryData a list of log
* @return the result json string
*/
static ObjectNode logsToJson(LinkedList<TelemetryData> telemetryData)
{
ObjectNode node = mapper.createObjectNode();
ArrayNode logs = mapper.createArrayNode();
for (TelemetryData data : telemetryData)
{
logs.add(data.toJson());
}
node.set("logs", logs);
return node;
}
/**
* convert a list of log to a JSON String
*
* @param telemetryData a list of log
* @return the result json string
*/
static String logsToString(LinkedList<TelemetryData> telemetryData)
{
return logsToJson(telemetryData).toString();
}
/**
* For test use only
*
* @return the number of cached logs
*/
public int bufferSize()
{
return this.logBatch.size();
}
/**
* For test use only
*
* @return a copy of the logs currently in the buffer
*/
public LinkedList<TelemetryData> logBuffer()
{
return new LinkedList<>(this.logBatch);
}
}
| /*
* Copyright (c) 2012-2019 Snowflake Computing Inc. All rights reserved.
*/
package IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3.telemetry;
import com.IMPORT_4.IMPORT_5.IMPORT_6.IMPORT_7;
import com.IMPORT_4.IMPORT_5.IMPORT_6.node.IMPORT_8;
import com.IMPORT_4.IMPORT_5.IMPORT_6.node.ObjectNode;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_9.IMPORT_10;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_9.IMPORT_11;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_9.ObjectMapperFactory;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_9.IMPORT_12;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3.IMPORT_13;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3.IMPORT_14;
import IMPORT_0.IMPORT_1.IMPORT_2.log.IMPORT_15;
import IMPORT_0.IMPORT_1.IMPORT_2.log.IMPORT_16;
import org.IMPORT_17.IMPORT_18.IMPORT_2.methods.HttpPost;
import org.IMPORT_17.IMPORT_18.entity.StringEntity;
import IMPORT_19.io.IMPORT_20;
import IMPORT_19.rmi.IMPORT_21;
import IMPORT_19.sql.IMPORT_22;
import IMPORT_19.sql.SQLException;
import IMPORT_19.IMPORT_23.IMPORT_24;
/**
* Copyright (c) 2018-2019 Snowflake Computing Inc. All rights reserved.
* <p>
* Telemetry Service Interface
*/
public class TelemetryClient implements Telemetry
{
private static final IMPORT_15 logger =
IMPORT_16.getLogger(IMPORT_12.class);
private static final CLASS_0 SF_PATH_TELEMETRY = "/telemetry/send";
// if the number of cached logs is larger than this threshold,
// the telemetry connector will flush the buffer automatically.
private final int VAR_0;
private static final int VAR_1 = 100;
private final CLASS_0 serverUrl;
private final CLASS_0 VAR_2;
private final IMPORT_12 VAR_3;
private IMPORT_24<TelemetryData> VAR_4;
private static final IMPORT_7 mapper =
ObjectMapperFactory.FUNC_0();
private boolean VAR_5;
private CLASS_1 VAR_6 = new CLASS_1();
//false if meet any error when sending metrics
private boolean VAR_7 = true;
private TelemetryClient(IMPORT_12 VAR_3, int VAR_8)
{
this.VAR_3 = VAR_3;
this.serverUrl = VAR_3.FUNC_2();
if (this.serverUrl.FUNC_3("/"))
{
this.VAR_2 =
this.serverUrl.FUNC_4(0, this.serverUrl.FUNC_5() - 1)
+ SF_PATH_TELEMETRY;
}
else
{
this.VAR_2 = this.serverUrl + SF_PATH_TELEMETRY;
}
this.VAR_4 = new IMPORT_24<>();
this.VAR_5 = false;
this.VAR_0 = VAR_8;
}
/**
* Return whether the client can be used to add/send metrics
*
* @return whether client is enabled
*/
public boolean isTelemetryEnabled()
{
return this.VAR_3.FUNC_6() && this.VAR_7;
}
/**
* Disable any use of the client to add/send metrics
*/
public void disableTelemetry()
{
this.VAR_7 = false;
}
/**
* Initialize the telemetry connector
*
* @param conn connection with the session to use for the connector
* @param flushSize maximum size of telemetry batch before flush
* @return a telemetry connector
*/
public static Telemetry FUNC_7(IMPORT_22 conn, int VAR_8)
{
try
{
return FUNC_7(conn.FUNC_8(IMPORT_13.class).FUNC_9(), VAR_8);
}
catch (SQLException VAR_9)
{
logger.FUNC_10("input connection is not a SnowflakeConnection");
return null;
}
}
/**
* Initialize the telemetry connector
*
* @param conn connection with the session to use for the connector
* @return a telemetry connector
*/
public static Telemetry FUNC_7(IMPORT_22 conn)
{
return FUNC_7(conn, VAR_1);
}
/**
* Initialize the telemetry connector
*
* @param session session to use for telemetry dumps
* @return a telemetry connector
*/
public static Telemetry FUNC_7(IMPORT_12 VAR_3)
{
return FUNC_7(VAR_3, VAR_1);
}
/**
* Initialize the telemetry connector
*
* @param session session to use for telemetry dumps
* @param flushSize maximum size of telemetry batch before flush
* @return a telemetry connector
*/
public static Telemetry FUNC_7(IMPORT_12 VAR_3, int VAR_8)
{
return new TelemetryClient(VAR_3, VAR_8);
}
/**
* Add log to batch to be submitted to telemetry. Send batch if forceFlushSize
* reached
*
* @param log entry to add
* @throws IOException if closed or uploading batch fails
*/
@Override
public void FUNC_11(TelemetryData log) throws IMPORT_20
{
if (VAR_5)
{
throw new IMPORT_20("Telemetry connector is closed");
}
if (!isTelemetryEnabled())
{
return; // if disable, do nothing
}
synchronized (VAR_6)
{
this.VAR_4.FUNC_12(log);
}
if (this.VAR_4.FUNC_13() >= this.VAR_0)
{
this.FUNC_14();
}
}
/**
* Add log to batch to be submitted to telemetry. Send batch if forceFlushSize
* reached
*
* @param message json node of log
* @param timeStamp timestamp to use for log
* @throws IOException if closed or uploading batch fails
*/
public void FUNC_11(ObjectNode message, long VAR_10) throws
IMPORT_20
{
this.FUNC_11(new TelemetryData(message, VAR_10));
}
/**
* Attempt to add log to batch, and suppress exceptions thrown in case of
* failure
*
* @param log entry to add
*/
@Override
public void FUNC_15(TelemetryData log)
{
try
{
FUNC_11(log);
}
catch (IMPORT_20 VAR_9)
{
logger.FUNC_10("Exception encountered while sending metrics to telemetry endpoint.", VAR_9);
}
}
/**
* Close telemetry connector and send any unsubmitted logs
*
* @throws IOException if closed or uploading batch fails
*/
@Override
public void FUNC_16() throws IMPORT_20
{
if (VAR_5)
{
throw new IMPORT_20("Telemetry connector is closed");
}
try
{
this.FUNC_14();
}
catch (IMPORT_20 VAR_11)
{
logger.FUNC_17("Send logs failed on closing", VAR_11);
}
finally
{
this.VAR_5 = true;
}
}
/**
* Return whether the client has been closed
*
* @return whether client is closed
*/
public boolean FUNC_1()
{
return this.VAR_5;
}
/**
* Send all cached logs to server
*
* @return whether the logs were sent successfully
* @throws IOException if closed or uploading batch fails
*/
@Override
public boolean FUNC_14() throws IMPORT_20
{
if (VAR_5)
{
throw new IMPORT_20("Telemetry connector is closed");
}
if (!isTelemetryEnabled())
{
return false;
}
IMPORT_24<TelemetryData> VAR_12;
synchronized (VAR_6)
{
VAR_12 = this.VAR_4;
this.VAR_4 = new IMPORT_24<>();
}
if (VAR_3.FUNC_1())
{
throw new IMPORT_21("Session is closed when sending log");
}
if (!VAR_12.FUNC_18())
{
//session shared with JDBC
CLASS_0 VAR_13 = this.VAR_3.FUNC_19();
HttpPost post = new HttpPost(this.VAR_2);
post.setEntity(new StringEntity(logsToString(VAR_12)));
post.setHeader("Content-type", "application/json");
post.setHeader("Authorization", "Snowflake Token=\"" + VAR_13 +
"\"");
CLASS_0 VAR_14 = null;
try
{
VAR_14 = IMPORT_10.FUNC_20(post, 1000, IMPORT_11.FAIL_OPEN);
}
catch (IMPORT_14 VAR_11)
{
disableTelemetry(); // when got error like 404 or bad request, disable telemetry in this telemetry instance
logger.FUNC_17(
"Telemetry request failed, " +
"response: {}, exception: {}", VAR_14, VAR_11.getMessage());
return false;
}
}
return true;
}
/**
* Send a log to the server, along with any existing logs waiting to be sent
*
* @param log entry to send
* @return whether the logs were sent successfully
* @throws IOException if closed or uploading batch fails
*/
public boolean sendLog(TelemetryData log) throws IMPORT_20
{
FUNC_11(log);
return FUNC_14();
}
/**
* Send a log to the server, along with any existing logs waiting to be sent
*
* @param message json node of log
* @param timeStamp timestamp to use for log
* @return whether the logs were sent successfully
* @throws IOException if closed or uploading batch fails
*/
public boolean sendLog(ObjectNode message, long VAR_10) throws IMPORT_20
{
return this.sendLog(new TelemetryData(message, VAR_10));
}
/**
* convert a list of log to a JSON object
*
* @param telemetryData a list of log
* @return the result json string
*/
static ObjectNode FUNC_21(IMPORT_24<TelemetryData> telemetryData)
{
ObjectNode node = mapper.FUNC_22();
IMPORT_8 VAR_15 = mapper.createArrayNode();
for (TelemetryData VAR_16 : telemetryData)
{
VAR_15.FUNC_12(VAR_16.FUNC_23());
}
node.set("logs", VAR_15);
return node;
}
/**
* convert a list of log to a JSON String
*
* @param telemetryData a list of log
* @return the result json string
*/
static CLASS_0 logsToString(IMPORT_24<TelemetryData> telemetryData)
{
return FUNC_21(telemetryData).FUNC_24();
}
/**
* For test use only
*
* @return the number of cached logs
*/
public int bufferSize()
{
return this.VAR_4.FUNC_13();
}
/**
* For test use only
*
* @return a copy of the logs currently in the buffer
*/
public IMPORT_24<TelemetryData> logBuffer()
{
return new IMPORT_24<>(this.VAR_4);
}
}
| 0.560464 | {'IMPORT_0': 'net', 'IMPORT_1': 'snowflake', 'IMPORT_2': 'client', 'IMPORT_3': 'jdbc', 'IMPORT_4': 'fasterxml', 'IMPORT_5': 'jackson', 'IMPORT_6': 'databind', 'IMPORT_7': 'ObjectMapper', 'IMPORT_8': 'ArrayNode', 'IMPORT_9': 'core', 'IMPORT_10': 'HttpUtil', 'IMPORT_11': 'OCSPMode', 'IMPORT_12': 'SFSession', 'IMPORT_13': 'SnowflakeConnectionV1', 'IMPORT_14': 'SnowflakeSQLException', 'IMPORT_15': 'SFLogger', 'IMPORT_16': 'SFLoggerFactory', 'IMPORT_17': 'apache', 'IMPORT_18': 'http', 'IMPORT_19': 'java', 'IMPORT_20': 'IOException', 'IMPORT_21': 'UnexpectedException', 'IMPORT_22': 'Connection', 'IMPORT_23': 'util', 'IMPORT_24': 'LinkedList', 'CLASS_0': 'String', 'VAR_0': 'forceFlushSize', 'VAR_1': 'DEFAULT_FORCE_FLUSH_SIZE', 'VAR_2': 'telemetryUrl', 'VAR_3': 'session', 'VAR_4': 'logBatch', 'FUNC_0': 'getObjectMapper', 'VAR_5': 'isClosed', 'FUNC_1': 'isClosed', 'CLASS_1': 'Object', 'VAR_6': 'locker', 'VAR_7': 'isTelemetryServiceAvailable', 'VAR_8': 'flushSize', 'FUNC_2': 'getUrl', 'FUNC_3': 'endsWith', 'FUNC_4': 'substring', 'FUNC_5': 'length', 'FUNC_6': 'isClientTelemetryEnabled', 'FUNC_7': 'createTelemetry', 'FUNC_8': 'unwrap', 'FUNC_9': 'getSfSession', 'VAR_9': 'ex', 'FUNC_10': 'debug', 'FUNC_11': 'addLogToBatch', 'FUNC_12': 'add', 'FUNC_13': 'size', 'FUNC_14': 'sendBatch', 'VAR_10': 'timeStamp', 'FUNC_15': 'tryAddLogToBatch', 'FUNC_16': 'close', 'VAR_11': 'e', 'FUNC_17': 'error', 'VAR_12': 'tmpList', 'FUNC_18': 'isEmpty', 'VAR_13': 'sessionToken', 'FUNC_19': 'getSessionToken', 'VAR_14': 'response', 'FUNC_20': 'executeGeneralRequest', 'FUNC_21': 'logsToJson', 'FUNC_22': 'createObjectNode', 'VAR_15': 'logs', 'VAR_16': 'data', 'FUNC_23': 'toJson', 'FUNC_24': 'toString'} | java | Hibrido | 11.65% |
package dev.backup.ravi.assignment.java;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
public class TestNG1 {
WebDriver driver;
WebElement txt_user_name;
WebElement txt_password;
WebElement btn_submit;
@Test()
public void valid_credntial()
{
init_login_locators();// locator method called here to find xpath
txt_user_name.sendKeys("john");
txt_password.sendKeys("<PASSWORD>");
btn_submit.click();
}
@Test()
public void invalid_credntial()
{
init_login_locators();// locator method called here to find xpath
txt_user_name.sendKeys("john");
txt_password.sendKeys("<PASSWORD>");
btn_submit.click();
}
@Test()
public void init_login_locators()
{
txt_user_name = driver.findElement(By.xpath("//input[@name='username' and @class='input']"));
txt_password = driver.findElement(By.xpath("//input[@name='password'and @class='input']"));
btn_submit = driver.findElement(By.xpath("//input[@value='Log In' and @type='submit']"));
}
@BeforeMethod
public void beforeMethod()
{
driver = new ChromeDriver();
driver.get("http://parabank.parasoft.com");
driver.manage().window().maximize();
}
@AfterMethod
public void afterMethod()
{
driver.close();
}
@BeforeClass
public void beforeClass()
{
System.setProperty("webdriver.chrome.driver","C:\\selenium\\chromedriver.exe");
}
/* @AfterClass
public void afterClass() {
}
@BeforeTest
public void beforeTest() {
}
@AfterTest
public void afterTest() {
}
*/
}
| package IMPORT_0.backup.ravi.assignment.java;
import IMPORT_1.testng.annotations.IMPORT_2;
import IMPORT_1.testng.annotations.IMPORT_3;
import IMPORT_1.testng.annotations.AfterMethod;
import IMPORT_1.testng.annotations.IMPORT_4;
import IMPORT_1.openqa.selenium.By;
import IMPORT_1.openqa.selenium.IMPORT_5;
import IMPORT_1.openqa.selenium.WebElement;
import IMPORT_1.openqa.selenium.chrome.IMPORT_6;
import IMPORT_1.testng.annotations.AfterClass;
import IMPORT_1.testng.annotations.BeforeTest;
import IMPORT_1.testng.annotations.IMPORT_7;
public class TestNG1 {
IMPORT_5 VAR_0;
WebElement txt_user_name;
WebElement txt_password;
WebElement btn_submit;
@IMPORT_2()
public void valid_credntial()
{
init_login_locators();// locator method called here to find xpath
txt_user_name.sendKeys("john");
txt_password.sendKeys("<PASSWORD>");
btn_submit.click();
}
@IMPORT_2()
public void invalid_credntial()
{
init_login_locators();// locator method called here to find xpath
txt_user_name.sendKeys("john");
txt_password.sendKeys("<PASSWORD>");
btn_submit.click();
}
@IMPORT_2()
public void init_login_locators()
{
txt_user_name = VAR_0.FUNC_0(By.FUNC_1("//input[@name='username' and @class='input']"));
txt_password = VAR_0.FUNC_0(By.FUNC_1("//input[@name='password'and @class='input']"));
btn_submit = VAR_0.FUNC_0(By.FUNC_1("//input[@value='Log In' and @type='submit']"));
}
@IMPORT_3
public void beforeMethod()
{
VAR_0 = new IMPORT_6();
VAR_0.FUNC_2("http://parabank.parasoft.com");
VAR_0.manage().window().maximize();
}
@AfterMethod
public void afterMethod()
{
VAR_0.close();
}
@IMPORT_4
public void beforeClass()
{
System.setProperty("webdriver.chrome.driver","C:\\selenium\\chromedriver.exe");
}
/* @AfterClass
public void afterClass() {
}
@BeforeTest
public void beforeTest() {
}
@AfterTest
public void afterTest() {
}
*/
}
| 0.479876 | {'IMPORT_0': 'dev', 'IMPORT_1': 'org', 'IMPORT_2': 'Test', 'IMPORT_3': 'BeforeMethod', 'IMPORT_4': 'BeforeClass', 'IMPORT_5': 'WebDriver', 'IMPORT_6': 'ChromeDriver', 'IMPORT_7': 'AfterTest', 'VAR_0': 'driver', 'FUNC_0': 'findElement', 'FUNC_1': 'xpath', 'FUNC_2': 'get'} | java | OOP | 62.10% |
//here we go with the functions
public void executeUpdate(String update) {
try {
if (update != null) {
stmt.executeUpdate(update);
}
else {
stmt.executeUpdate(valueString);
}
}
catch (SQLException ex) {
close();
System.out.println("SQLException3: " + ex.getMessage() +
"\nSQLState: " + ex.getSQLState() +
"\nVendorError: " + ex.getErrorCode() +
"\nQuery was: " + update
);
}
} | //here we go with the functions
public void FUNC_0(CLASS_0 update) {
try {
if (update != null) {
stmt.FUNC_0(update);
}
else {
stmt.FUNC_0(VAR_0);
}
}
catch (CLASS_1 VAR_1) {
FUNC_1();
VAR_2.VAR_3.FUNC_2("SQLException3: " + VAR_1.FUNC_3() +
"\nSQLState: " + VAR_1.FUNC_4() +
"\nVendorError: " + VAR_1.FUNC_5() +
"\nQuery was: " + update
);
}
} | 0.888064 | {'FUNC_0': 'executeUpdate', 'CLASS_0': 'String', 'VAR_0': 'valueString', 'CLASS_1': 'SQLException', 'VAR_1': 'ex', 'FUNC_1': 'close', 'VAR_2': 'System', 'VAR_3': 'out', 'FUNC_2': 'println', 'FUNC_3': 'getMessage', 'FUNC_4': 'getSQLState', 'FUNC_5': 'getErrorCode'} | java | Procedural | 80.30% |
import java.io.IOException;
import java.util.Arrays;
public class A110 {
public static void main(String[] args) throws IOException {
java.io.BufferedReader r = new java.io.BufferedReader(
new java.io.InputStreamReader(System.in));
int number = Integer.parseInt(r.readLine());
String [][] data = new String[number][];
for(int i=0; i<number; i++)
data[i] = r.readLine().split(" ");
int [] columns = new int [data[0].length];
int [] rows = new int [number];
Arrays.fill(columns, 0);
Arrays.fill(rows, 0);
for(int i=0; i<number; i++){
for(int j=0; j<data[0].length; j++) {
rows[i]+= Integer.parseInt(data[i][j]);
}
}
for(int i=0; i<data[0].length; i++){
for(int j=0; j<number; j++) {
columns[i]+= Integer.parseInt(data[j][i]);
}
}
int result = 0;
for(int i=0; i<data[0].length; i++){
for(int j=0; j<number; j++) {
if(columns[j] > rows[i])
result++;
}
}
System.out.println(result);
}
}
| import IMPORT_0.IMPORT_1.IOException;
import IMPORT_0.IMPORT_2.Arrays;
public class A110 {
public static void FUNC_0(String[] args) throws IOException {
IMPORT_0.IMPORT_1.CLASS_0 VAR_0 = new IMPORT_0.IMPORT_1.CLASS_0(
new IMPORT_0.IMPORT_1.CLASS_1(System.VAR_1));
int VAR_2 = Integer.FUNC_1(VAR_0.readLine());
String [][] data = new String[VAR_2][];
for(int i=0; i<VAR_2; i++)
data[i] = VAR_0.readLine().split(" ");
int [] VAR_3 = new int [data[0].length];
int [] VAR_4 = new int [VAR_2];
Arrays.FUNC_2(VAR_3, 0);
Arrays.FUNC_2(VAR_4, 0);
for(int i=0; i<VAR_2; i++){
for(int j=0; j<data[0].length; j++) {
VAR_4[i]+= Integer.FUNC_1(data[i][j]);
}
}
for(int i=0; i<data[0].length; i++){
for(int j=0; j<VAR_2; j++) {
VAR_3[i]+= Integer.FUNC_1(data[j][i]);
}
}
int VAR_5 = 0;
for(int i=0; i<data[0].length; i++){
for(int j=0; j<VAR_2; j++) {
if(VAR_3[j] > VAR_4[i])
VAR_5++;
}
}
System.out.println(VAR_5);
}
}
| 0.676755 | {'IMPORT_0': 'java', 'IMPORT_1': 'io', 'IMPORT_2': 'util', 'FUNC_0': 'main', 'CLASS_0': 'BufferedReader', 'VAR_0': 'r', 'CLASS_1': 'InputStreamReader', 'VAR_1': 'in', 'VAR_2': 'number', 'FUNC_1': 'parseInt', 'VAR_3': 'columns', 'VAR_4': 'rows', 'FUNC_2': 'fill', 'VAR_5': 'result'} | java | OOP | 19.17% |
/*
* This file is generated by jOOQ.
*/
package fi.morabotti.travelapp.db.tables;
import fi.morabotti.travelapp.db.Indexes;
import fi.morabotti.travelapp.db.Keys;
import fi.morabotti.travelapp.db.Travelapp;
import fi.morabotti.travelapp.db.tables.records.CustomersRecord;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Generated;
import org.jooq.Field;
import org.jooq.ForeignKey;
import org.jooq.Identity;
import org.jooq.Index;
import org.jooq.Name;
import org.jooq.Record;
import org.jooq.Schema;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.UniqueKey;
import org.jooq.impl.DSL;
import org.jooq.impl.TableImpl;
/**
* This class is generated by jOOQ.
*/
@Generated(
value = {
"http://www.jooq.org",
"jOOQ version:3.11.11"
},
comments = "This class is generated by jOOQ"
)
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class Customers extends TableImpl<CustomersRecord> {
private static final long serialVersionUID = -330429307;
/**
* The reference instance of <code>travelapp.customers</code>
*/
public static final Customers CUSTOMERS = new Customers();
/**
* The class holding records for this type
*/
@Override
public Class<CustomersRecord> getRecordType() {
return CustomersRecord.class;
}
/**
* The column <code>travelapp.customers.id</code>.
*/
public final TableField<CustomersRecord, Long> ID = createField("id", org.jooq.impl.SQLDataType.BIGINT.nullable(false).identity(true), this, "");
/**
* The column <code>travelapp.customers.first_name</code>.
*/
public final TableField<CustomersRecord, String> FIRST_NAME = createField("first_name", org.jooq.impl.SQLDataType.VARCHAR(255).nullable(false), this, "");
/**
* The column <code>travelapp.customers.last_name</code>.
*/
public final TableField<CustomersRecord, String> LAST_NAME = createField("last_name", org.jooq.impl.SQLDataType.VARCHAR(255).nullable(false), this, "");
/**
* The column <code>travelapp.customers.email</code>.
*/
public final TableField<CustomersRecord, String> EMAIL = createField("email", org.jooq.impl.SQLDataType.VARCHAR(255).nullable(false), this, "");
/**
* The column <code>travelapp.customers.age</code>.
*/
public final TableField<CustomersRecord, Integer> AGE = createField("age", org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "");
/**
* The column <code>travelapp.customers.created</code>.
*/
public final TableField<CustomersRecord, Timestamp> CREATED = createField("created", org.jooq.impl.SQLDataType.TIMESTAMP.nullable(false).defaultValue(org.jooq.impl.DSL.field("CURRENT_TIMESTAMP", org.jooq.impl.SQLDataType.TIMESTAMP)), this, "");
/**
* Create a <code>travelapp.customers</code> table reference
*/
public Customers() {
this(DSL.name("customers"), null);
}
/**
* Create an aliased <code>travelapp.customers</code> table reference
*/
public Customers(String alias) {
this(DSL.name(alias), CUSTOMERS);
}
/**
* Create an aliased <code>travelapp.customers</code> table reference
*/
public Customers(Name alias) {
this(alias, CUSTOMERS);
}
private Customers(Name alias, Table<CustomersRecord> aliased) {
this(alias, aliased, null);
}
private Customers(Name alias, Table<CustomersRecord> aliased, Field<?>[] parameters) {
super(alias, null, aliased, parameters, DSL.comment(""));
}
public <O extends Record> Customers(Table<O> child, ForeignKey<O, CustomersRecord> key) {
super(child, key, CUSTOMERS);
}
/**
* {@inheritDoc}
*/
@Override
public Schema getSchema() {
return Travelapp.TRAVELAPP;
}
/**
* {@inheritDoc}
*/
@Override
public List<Index> getIndexes() {
return Arrays.<Index>asList(Indexes.CUSTOMERS_EMAIL, Indexes.CUSTOMERS_PRIMARY);
}
/**
* {@inheritDoc}
*/
@Override
public Identity<CustomersRecord, Long> getIdentity() {
return Keys.IDENTITY_CUSTOMERS;
}
/**
* {@inheritDoc}
*/
@Override
public UniqueKey<CustomersRecord> getPrimaryKey() {
return Keys.KEY_CUSTOMERS_PRIMARY;
}
/**
* {@inheritDoc}
*/
@Override
public List<UniqueKey<CustomersRecord>> getKeys() {
return Arrays.<UniqueKey<CustomersRecord>>asList(Keys.KEY_CUSTOMERS_PRIMARY, Keys.KEY_CUSTOMERS_EMAIL);
}
/**
* {@inheritDoc}
*/
@Override
public Customers as(String alias) {
return new Customers(DSL.name(alias), this);
}
/**
* {@inheritDoc}
*/
@Override
public Customers as(Name alias) {
return new Customers(alias, this);
}
/**
* Rename this table
*/
@Override
public Customers rename(String name) {
return new Customers(DSL.name(name), null);
}
/**
* Rename this table
*/
@Override
public Customers rename(Name name) {
return new Customers(name, null);
}
}
| /*
* This file is generated by jOOQ.
*/
package IMPORT_0.IMPORT_1.travelapp.IMPORT_2.tables;
import IMPORT_0.IMPORT_1.travelapp.IMPORT_2.IMPORT_3;
import IMPORT_0.IMPORT_1.travelapp.IMPORT_2.IMPORT_4;
import IMPORT_0.IMPORT_1.travelapp.IMPORT_2.IMPORT_5;
import IMPORT_0.IMPORT_1.travelapp.IMPORT_2.tables.records.IMPORT_6;
import IMPORT_7.IMPORT_8.IMPORT_9;
import IMPORT_7.util.Arrays;
import IMPORT_7.util.IMPORT_10;
import IMPORT_11.IMPORT_12.IMPORT_13;
import IMPORT_14.IMPORT_15.IMPORT_16;
import IMPORT_14.IMPORT_15.IMPORT_17;
import IMPORT_14.IMPORT_15.Identity;
import IMPORT_14.IMPORT_15.Index;
import IMPORT_14.IMPORT_15.IMPORT_18;
import IMPORT_14.IMPORT_15.Record;
import IMPORT_14.IMPORT_15.Schema;
import IMPORT_14.IMPORT_15.IMPORT_19;
import IMPORT_14.IMPORT_15.IMPORT_20;
import IMPORT_14.IMPORT_15.IMPORT_21;
import IMPORT_14.IMPORT_15.IMPORT_22.DSL;
import IMPORT_14.IMPORT_15.IMPORT_22.IMPORT_23;
/**
* This class is generated by jOOQ.
*/
@IMPORT_13(
value = {
"http://www.jooq.org",
"jOOQ version:3.11.11"
},
VAR_0 = "This class is generated by jOOQ"
)
@VAR_1({ "all", "unchecked", "rawtypes" })
public class CLASS_0 extends IMPORT_23<IMPORT_6> {
private static final long VAR_2 = -330429307;
/**
* The reference instance of <code>travelapp.customers</code>
*/
public static final CLASS_0 VAR_3 = new CLASS_0();
/**
* The class holding records for this type
*/
@VAR_4
public CLASS_1<IMPORT_6> FUNC_0() {
return IMPORT_6.class;
}
/**
* The column <code>travelapp.customers.id</code>.
*/
public final IMPORT_20<IMPORT_6, CLASS_2> VAR_5 = FUNC_1("id", IMPORT_14.IMPORT_15.IMPORT_22.VAR_6.VAR_7.FUNC_2(false).FUNC_3(true), this, "");
/**
* The column <code>travelapp.customers.first_name</code>.
*/
public final IMPORT_20<IMPORT_6, CLASS_3> VAR_8 = FUNC_1("first_name", IMPORT_14.IMPORT_15.IMPORT_22.VAR_6.FUNC_4(255).FUNC_2(false), this, "");
/**
* The column <code>travelapp.customers.last_name</code>.
*/
public final IMPORT_20<IMPORT_6, CLASS_3> VAR_9 = FUNC_1("last_name", IMPORT_14.IMPORT_15.IMPORT_22.VAR_6.FUNC_4(255).FUNC_2(false), this, "");
/**
* The column <code>travelapp.customers.email</code>.
*/
public final IMPORT_20<IMPORT_6, CLASS_3> VAR_10 = FUNC_1("email", IMPORT_14.IMPORT_15.IMPORT_22.VAR_6.FUNC_4(255).FUNC_2(false), this, "");
/**
* The column <code>travelapp.customers.age</code>.
*/
public final IMPORT_20<IMPORT_6, CLASS_4> VAR_11 = FUNC_1("age", IMPORT_14.IMPORT_15.IMPORT_22.VAR_6.VAR_12.FUNC_2(false), this, "");
/**
* The column <code>travelapp.customers.created</code>.
*/
public final IMPORT_20<IMPORT_6, IMPORT_9> VAR_13 = FUNC_1("created", IMPORT_14.IMPORT_15.IMPORT_22.VAR_6.TIMESTAMP.FUNC_2(false).defaultValue(IMPORT_14.IMPORT_15.IMPORT_22.DSL.field("CURRENT_TIMESTAMP", IMPORT_14.IMPORT_15.IMPORT_22.VAR_6.TIMESTAMP)), this, "");
/**
* Create a <code>travelapp.customers</code> table reference
*/
public CLASS_0() {
this(DSL.FUNC_5("customers"), null);
}
/**
* Create an aliased <code>travelapp.customers</code> table reference
*/
public CLASS_0(CLASS_3 alias) {
this(DSL.FUNC_5(alias), VAR_3);
}
/**
* Create an aliased <code>travelapp.customers</code> table reference
*/
public CLASS_0(IMPORT_18 alias) {
this(alias, VAR_3);
}
private CLASS_0(IMPORT_18 alias, IMPORT_19<IMPORT_6> VAR_15) {
this(alias, VAR_15, null);
}
private CLASS_0(IMPORT_18 alias, IMPORT_19<IMPORT_6> VAR_15, IMPORT_16<?>[] VAR_16) {
super(alias, null, VAR_15, VAR_16, DSL.comment(""));
}
public <CLASS_5 extends Record> CLASS_0(IMPORT_19<CLASS_5> VAR_17, IMPORT_17<CLASS_5, IMPORT_6> VAR_18) {
super(VAR_17, VAR_18, VAR_3);
}
/**
* {@inheritDoc}
*/
@VAR_4
public Schema FUNC_6() {
return IMPORT_5.VAR_19;
}
/**
* {@inheritDoc}
*/
@VAR_4
public IMPORT_10<Index> FUNC_7() {
return Arrays.<Index>FUNC_8(IMPORT_3.VAR_20, IMPORT_3.VAR_21);
}
/**
* {@inheritDoc}
*/
@VAR_4
public Identity<IMPORT_6, CLASS_2> FUNC_9() {
return IMPORT_4.VAR_22;
}
/**
* {@inheritDoc}
*/
@VAR_4
public IMPORT_21<IMPORT_6> FUNC_10() {
return IMPORT_4.VAR_23;
}
/**
* {@inheritDoc}
*/
@VAR_4
public IMPORT_10<IMPORT_21<IMPORT_6>> FUNC_11() {
return Arrays.<IMPORT_21<IMPORT_6>>FUNC_8(IMPORT_4.VAR_23, IMPORT_4.KEY_CUSTOMERS_EMAIL);
}
/**
* {@inheritDoc}
*/
@VAR_4
public CLASS_0 FUNC_12(CLASS_3 alias) {
return new CLASS_0(DSL.FUNC_5(alias), this);
}
/**
* {@inheritDoc}
*/
@VAR_4
public CLASS_0 FUNC_12(IMPORT_18 alias) {
return new CLASS_0(alias, this);
}
/**
* Rename this table
*/
@VAR_4
public CLASS_0 FUNC_13(CLASS_3 VAR_14) {
return new CLASS_0(DSL.FUNC_5(VAR_14), null);
}
/**
* Rename this table
*/
@VAR_4
public CLASS_0 FUNC_13(IMPORT_18 VAR_14) {
return new CLASS_0(VAR_14, null);
}
}
| 0.817985 | {'IMPORT_0': 'fi', 'IMPORT_1': 'morabotti', 'IMPORT_2': 'db', 'IMPORT_3': 'Indexes', 'IMPORT_4': 'Keys', 'IMPORT_5': 'Travelapp', 'IMPORT_6': 'CustomersRecord', 'IMPORT_7': 'java', 'IMPORT_8': 'sql', 'IMPORT_9': 'Timestamp', 'IMPORT_10': 'List', 'IMPORT_11': 'javax', 'IMPORT_12': 'annotation', 'IMPORT_13': 'Generated', 'IMPORT_14': 'org', 'IMPORT_15': 'jooq', 'IMPORT_16': 'Field', 'IMPORT_17': 'ForeignKey', 'IMPORT_18': 'Name', 'IMPORT_19': 'Table', 'IMPORT_20': 'TableField', 'IMPORT_21': 'UniqueKey', 'IMPORT_22': 'impl', 'IMPORT_23': 'TableImpl', 'VAR_0': 'comments', 'VAR_1': 'SuppressWarnings', 'CLASS_0': 'Customers', 'VAR_2': 'serialVersionUID', 'VAR_3': 'CUSTOMERS', 'VAR_4': 'Override', 'CLASS_1': 'Class', 'FUNC_0': 'getRecordType', 'CLASS_2': 'Long', 'VAR_5': 'ID', 'FUNC_1': 'createField', 'VAR_6': 'SQLDataType', 'VAR_7': 'BIGINT', 'FUNC_2': 'nullable', 'FUNC_3': 'identity', 'CLASS_3': 'String', 'VAR_8': 'FIRST_NAME', 'FUNC_4': 'VARCHAR', 'VAR_9': 'LAST_NAME', 'VAR_10': 'EMAIL', 'CLASS_4': 'Integer', 'VAR_11': 'AGE', 'VAR_12': 'INTEGER', 'VAR_13': 'CREATED', 'FUNC_5': 'name', 'VAR_14': 'name', 'VAR_15': 'aliased', 'VAR_16': 'parameters', 'CLASS_5': 'O', 'VAR_17': 'child', 'VAR_18': 'key', 'FUNC_6': 'getSchema', 'VAR_19': 'TRAVELAPP', 'FUNC_7': 'getIndexes', 'FUNC_8': 'asList', 'VAR_20': 'CUSTOMERS_EMAIL', 'VAR_21': 'CUSTOMERS_PRIMARY', 'FUNC_9': 'getIdentity', 'VAR_22': 'IDENTITY_CUSTOMERS', 'FUNC_10': 'getPrimaryKey', 'VAR_23': 'KEY_CUSTOMERS_PRIMARY', 'FUNC_11': 'getKeys', 'FUNC_12': 'as', 'FUNC_13': 'rename'} | java | OOP | 17.17% |
package org.krugler.yalder.hash;
import static org.junit.Assert.*;
import org.junit.Test;
public class HashTokenizerTest {
@Test
public void testManyIncrementalAdds() throws Exception {
final int maxNGramLength = 3;
HashTokenizer tokenizer = new HashTokenizer(maxNGramLength);
final int numBigrams = 1000;
int numNGrams = 0;
for (int i = 0; i < numBigrams; i++) {
tokenizer.addText("ab");
while (tokenizer.hasNext()) {
tokenizer.next();
numNGrams += 1;
}
}
tokenizer.complete();
while (tokenizer.hasNext()) {
tokenizer.next();
numNGrams += 1;
}
// We should get maxNGramLength * (N - 1) ngrams. Since the tokenizer
// adds a space at the beginning & end, this means N = chars + 2.
final int totalChars = (numBigrams * 2) + 2;
final int exectedNGrams = maxNGramLength * (totalChars - 1);
assertEquals(exectedNGrams, numNGrams);
}
@Test
public void testIncrementalAdd() throws Exception {
final int maxNGramLength = 3;
HashTokenizer tokenizer = new HashTokenizer(maxNGramLength);
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" "), tokenizer.next());
assertFalse(tokenizer.hasNext());
tokenizer.addText("ab");
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" a"), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" ab"), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("a"), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("ab"), tokenizer.next());
assertFalse(tokenizer.hasNext());
tokenizer.addText("c");
// Buffer has " abc". We should be able to return all ngrams
// from position 1 now.
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("abc"), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("b"), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("bc"), tokenizer.next());
assertFalse(tokenizer.hasNext());
tokenizer.complete();
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("bc "), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("c"), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("c "), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" "), tokenizer.next());
assertFalse(tokenizer.hasNext());
}
@Test
public void testReset() throws Exception {
final int maxNGramLength = 3;
HashTokenizer tokenizer = new HashTokenizer("superduper", maxNGramLength);
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" "), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" s"), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" su"), tokenizer.next());
tokenizer.reset();
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" "), tokenizer.next());
assertFalse(tokenizer.hasNext());
}
}
| package org.krugler.yalder.hash;
import static org.junit.Assert.*;
import org.junit.Test;
public class HashTokenizerTest {
@Test
public void testManyIncrementalAdds() throws Exception {
final int maxNGramLength = 3;
HashTokenizer tokenizer = new HashTokenizer(maxNGramLength);
final int numBigrams = 1000;
int numNGrams = 0;
for (int i = 0; i < numBigrams; i++) {
tokenizer.addText("ab");
while (tokenizer.hasNext()) {
tokenizer.next();
numNGrams += 1;
}
}
tokenizer.complete();
while (tokenizer.hasNext()) {
tokenizer.next();
numNGrams += 1;
}
// We should get maxNGramLength * (N - 1) ngrams. Since the tokenizer
// adds a space at the beginning & end, this means N = chars + 2.
final int totalChars = (numBigrams * 2) + 2;
final int exectedNGrams = maxNGramLength * (totalChars - 1);
assertEquals(exectedNGrams, numNGrams);
}
@Test
public void FUNC_0() throws Exception {
final int maxNGramLength = 3;
HashTokenizer tokenizer = new HashTokenizer(maxNGramLength);
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" "), tokenizer.next());
assertFalse(tokenizer.hasNext());
tokenizer.addText("ab");
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" a"), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" ab"), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("a"), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("ab"), tokenizer.next());
assertFalse(tokenizer.hasNext());
tokenizer.addText("c");
// Buffer has " abc". We should be able to return all ngrams
// from position 1 now.
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("abc"), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("b"), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("bc"), tokenizer.next());
assertFalse(tokenizer.hasNext());
tokenizer.complete();
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("bc "), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("c"), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash("c "), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" "), tokenizer.next());
assertFalse(tokenizer.hasNext());
}
@Test
public void testReset() throws Exception {
final int maxNGramLength = 3;
HashTokenizer tokenizer = new HashTokenizer("superduper", maxNGramLength);
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" "), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" s"), tokenizer.next());
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" su"), tokenizer.next());
tokenizer.reset();
assertTrue(tokenizer.hasNext());
assertEquals(HashTokenizer.calcHash(" "), tokenizer.next());
assertFalse(tokenizer.hasNext());
}
}
| 0.056757 | {'FUNC_0': 'testIncrementalAdd'} | java | OOP | 11.49% |
package com.kwery.tests.util;
import com.kwery.controllers.apis.OnboardingApiController;
import com.kwery.models.User;
import com.kwery.tests.fluentlenium.user.login.UserLoginPage;
import org.fluentlenium.adapter.junit.FluentTest;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
import static com.kwery.tests.fluentlenium.utils.DbUtil.userDbSetUp;
import static junit.framework.TestCase.fail;
public class LoginRule implements TestRule {
protected User loggedInUser;
protected boolean superUser = false;
protected NinjaServerRule ninjaServerRule;
protected FluentTest fluentTest;
public LoginRule(NinjaServerRule ninjaServerRule, FluentTest fluentTest) {
this.ninjaServerRule = ninjaServerRule;
this.fluentTest = fluentTest;
}
public LoginRule(NinjaServerRule ninjaServerRule, FluentTest fluentTest, boolean superUser) {
this.ninjaServerRule = ninjaServerRule;
this.fluentTest = fluentTest;
this.superUser = superUser;
}
@Override
public Statement apply(Statement base, Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
loggedInUser = TestUtil.user();
loggedInUser.setSuperUser(superUser);
userDbSetUp(loggedInUser);
//So that onboarding flows do not kick in automatically on logging in
System.setProperty(OnboardingApiController.TEST_ONBOARDING_SYSTEM_KEY, "false");
UserLoginPage loginPage = fluentTest.newInstance(UserLoginPage.class);
loginPage.go();
if (!loginPage.isRendered()) {
fail("Login page is not rendered");
}
loginPage.submitForm(loggedInUser.getEmail(), loggedInUser.getPassword());
loginPage.waitForModalDisappearance();
base.evaluate();
}
};
}
public User getLoggedInUser() {
return loggedInUser;
}
}
| package IMPORT_0.kwery.tests.IMPORT_1;
import IMPORT_0.kwery.IMPORT_2.IMPORT_3.OnboardingApiController;
import IMPORT_0.kwery.models.IMPORT_4;
import IMPORT_0.kwery.tests.fluentlenium.user.IMPORT_5.IMPORT_6;
import IMPORT_7.fluentlenium.adapter.junit.IMPORT_8;
import IMPORT_7.junit.rules.IMPORT_9;
import IMPORT_7.junit.IMPORT_10.IMPORT_11;
import IMPORT_7.junit.runners.model.IMPORT_12;
import static IMPORT_0.kwery.tests.fluentlenium.utils.DbUtil.IMPORT_13;
import static junit.IMPORT_14.IMPORT_15.IMPORT_16;
public class CLASS_0 implements IMPORT_9 {
protected IMPORT_4 VAR_0;
protected boolean superUser = false;
protected CLASS_1 VAR_1;
protected IMPORT_8 VAR_2;
public CLASS_0(CLASS_1 VAR_1, IMPORT_8 VAR_2) {
this.VAR_1 = VAR_1;
this.VAR_2 = VAR_2;
}
public CLASS_0(CLASS_1 VAR_1, IMPORT_8 VAR_2, boolean superUser) {
this.VAR_1 = VAR_1;
this.VAR_2 = VAR_2;
this.superUser = superUser;
}
@VAR_3
public IMPORT_12 apply(IMPORT_12 VAR_4, IMPORT_11 VAR_5) {
return new IMPORT_12() {
@VAR_3
public void evaluate() throws CLASS_2 {
VAR_0 = TestUtil.user();
VAR_0.FUNC_0(superUser);
IMPORT_13(VAR_0);
//So that onboarding flows do not kick in automatically on logging in
System.setProperty(OnboardingApiController.VAR_6, "false");
IMPORT_6 VAR_7 = VAR_2.FUNC_1(IMPORT_6.class);
VAR_7.FUNC_2();
if (!VAR_7.FUNC_3()) {
IMPORT_16("Login page is not rendered");
}
VAR_7.submitForm(VAR_0.FUNC_4(), VAR_0.getPassword());
VAR_7.waitForModalDisappearance();
VAR_4.evaluate();
}
};
}
public IMPORT_4 FUNC_5() {
return VAR_0;
}
}
| 0.615238 | {'IMPORT_0': 'com', 'IMPORT_1': 'util', 'IMPORT_2': 'controllers', 'IMPORT_3': 'apis', 'IMPORT_4': 'User', 'IMPORT_5': 'login', 'IMPORT_6': 'UserLoginPage', 'IMPORT_7': 'org', 'IMPORT_8': 'FluentTest', 'IMPORT_9': 'TestRule', 'IMPORT_10': 'runner', 'IMPORT_11': 'Description', 'IMPORT_12': 'Statement', 'IMPORT_13': 'userDbSetUp', 'IMPORT_14': 'framework', 'IMPORT_15': 'TestCase', 'IMPORT_16': 'fail', 'CLASS_0': 'LoginRule', 'VAR_0': 'loggedInUser', 'CLASS_1': 'NinjaServerRule', 'VAR_1': 'ninjaServerRule', 'VAR_2': 'fluentTest', 'VAR_3': 'Override', 'VAR_4': 'base', 'VAR_5': 'description', 'CLASS_2': 'Throwable', 'FUNC_0': 'setSuperUser', 'VAR_6': 'TEST_ONBOARDING_SYSTEM_KEY', 'VAR_7': 'loginPage', 'FUNC_1': 'newInstance', 'FUNC_2': 'go', 'FUNC_3': 'isRendered', 'FUNC_4': 'getEmail', 'FUNC_5': 'getLoggedInUser'} | java | OOP | 78.45% |
package enums;
import com.fasterxml.jackson.annotation.JsonValue;
public enum Status {
AVAILABLE("available"),
PENDING("pending"),
SOLD("sold");
private final String value;
Status(String value) {
this.value = value;
}
@JsonValue
public String getValue() {
return value;
}
}
| package VAR_0;
import com.IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3;
public enum CLASS_0 {
VAR_1("available"),
VAR_2("pending"),
VAR_3("sold");
private final CLASS_1 VAR_4;
CLASS_0(CLASS_1 VAR_4) {
this.VAR_4 = VAR_4;
}
@IMPORT_3
public CLASS_1 FUNC_0() {
return VAR_4;
}
}
| 0.925392 | {'VAR_0': 'enums', 'IMPORT_0': 'fasterxml', 'IMPORT_1': 'jackson', 'IMPORT_2': 'annotation', 'IMPORT_3': 'JsonValue', 'CLASS_0': 'Status', 'VAR_1': 'AVAILABLE', 'VAR_2': 'PENDING', 'VAR_3': 'SOLD', 'CLASS_1': 'String', 'VAR_4': 'value', 'FUNC_0': 'getValue'} | java | Texto | 26.09% |
/**
* Builder class that is used to build {@link Email} instances
*/
public static class Builder extends MultiValuedAttribute.Builder {
/**
* Pattern comes from: http://www.w3.org/TR/html5/forms.html#valid-e-mail-address
*/
public static final Pattern VALIDATION_PATTERN = Pattern.compile("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@" +
"[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$");
private Type type;
public Builder() {
}
/**
* builds an Builder based of the given Attribute
*
* @param email existing Attribute
*/
public Builder(Email email) {
super(email);
type = email.type;
}
@Deprecated
@Override
public Builder setOperation(String operation) {
super.setOperation(operation);
return this;
}
@Override
public Builder setDisplay(String display) {
super.setDisplay(display);
return this;
}
/**
* Sets the email value.
*
* @param value the email attribute
* @return the builder itself
* @throws SCIMDataValidationException in case the value is not a well-formed email
*/
@Override
public Builder setValue(String value) {
Matcher matcher = VALIDATION_PATTERN.matcher(value);
if (!matcher.matches()) {
throw new SCIMDataValidationException("The value '" + value + "' is not a well-formed email.");
}
super.setValue(value);
return this;
}
/**
* Sets the label indicating the attribute's function (See {@link Email#getType()}).
*
* @param type the type of the attribute
* @return the builder itself
*/
public Builder setType(Type type) {
this.type = type;
return this;
}
@Override
public Builder setPrimary(boolean primary) {
super.setPrimary(primary);
return this;
}
@Override
public Email build() {
return new Email(this);
}
} | /**
* Builder class that is used to build {@link Email} instances
*/
public static class CLASS_0 extends CLASS_1.CLASS_0 {
/**
* Pattern comes from: http://www.w3.org/TR/html5/forms.html#valid-e-mail-address
*/
public static final CLASS_2 VAR_1 = VAR_0.FUNC_0("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@" +
"[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$");
private CLASS_3 type;
public CLASS_0() {
}
/**
* builds an Builder based of the given Attribute
*
* @param email existing Attribute
*/
public CLASS_0(CLASS_4 VAR_2) {
super(VAR_2);
type = VAR_2.type;
}
@VAR_3
@VAR_4
public CLASS_0 FUNC_1(CLASS_5 VAR_5) {
super.FUNC_1(VAR_5);
return this;
}
@VAR_4
public CLASS_0 FUNC_2(CLASS_5 display) {
super.FUNC_2(display);
return this;
}
/**
* Sets the email value.
*
* @param value the email attribute
* @return the builder itself
* @throws SCIMDataValidationException in case the value is not a well-formed email
*/
@VAR_4
public CLASS_0 FUNC_3(CLASS_5 VAR_6) {
CLASS_6 VAR_7 = VAR_1.FUNC_4(VAR_6);
if (!VAR_7.FUNC_5()) {
throw new CLASS_7("The value '" + VAR_6 + "' is not a well-formed email.");
}
super.FUNC_3(VAR_6);
return this;
}
/**
* Sets the label indicating the attribute's function (See {@link Email#getType()}).
*
* @param type the type of the attribute
* @return the builder itself
*/
public CLASS_0 FUNC_6(CLASS_3 type) {
this.type = type;
return this;
}
@VAR_4
public CLASS_0 FUNC_7(boolean VAR_8) {
super.FUNC_7(VAR_8);
return this;
}
@VAR_4
public CLASS_4 FUNC_8() {
return new CLASS_4(this);
}
} | 0.809841 | {'CLASS_0': 'Builder', 'CLASS_1': 'MultiValuedAttribute', 'CLASS_2': 'Pattern', 'VAR_0': 'Pattern', 'VAR_1': 'VALIDATION_PATTERN', 'FUNC_0': 'compile', 'CLASS_3': 'Type', 'CLASS_4': 'Email', 'VAR_2': 'email', 'VAR_3': 'Deprecated', 'VAR_4': 'Override', 'FUNC_1': 'setOperation', 'CLASS_5': 'String', 'VAR_5': 'operation', 'FUNC_2': 'setDisplay', 'FUNC_3': 'setValue', 'VAR_6': 'value', 'CLASS_6': 'Matcher', 'VAR_7': 'matcher', 'FUNC_4': 'matcher', 'FUNC_5': 'matches', 'CLASS_7': 'SCIMDataValidationException', 'FUNC_6': 'setType', 'FUNC_7': 'setPrimary', 'VAR_8': 'primary', 'FUNC_8': 'build'} | java | OOP | 16.85% |
package com.home.onlineshop.service.ware;
import com.home.onlineshop.dto.WareTypeDto;
public interface WareTypeService {
WareTypeDto create(String wareType, Long category);
Iterable<WareTypeDto> getAll();
WareTypeDto lock(Long id);
WareTypeDto unlock(Long id);
void delete(Long id);
}
| package com.IMPORT_0.IMPORT_1.service.IMPORT_2;
import com.IMPORT_0.IMPORT_1.dto.WareTypeDto;
public interface CLASS_0 {
WareTypeDto create(String VAR_0, Long VAR_1);
Iterable<WareTypeDto> FUNC_0();
WareTypeDto lock(Long VAR_2);
WareTypeDto FUNC_1(Long VAR_2);
void delete(Long VAR_2);
}
| 0.241855 | {'IMPORT_0': 'home', 'IMPORT_1': 'onlineshop', 'IMPORT_2': 'ware', 'CLASS_0': 'WareTypeService', 'VAR_0': 'wareType', 'VAR_1': 'category', 'FUNC_0': 'getAll', 'VAR_2': 'id', 'FUNC_1': 'unlock'} | java | Texto | 33.33% |
package com.vaguehope.morrigan.player;
import java.util.Collection;
import com.vaguehope.morrigan.model.Register;
public interface PlayerRegister extends Register<Player> {
Collection<Player> getAll ();
Player get (String id);
LocalPlayer makeLocal (String name, LocalPlayerSupport localPlayerSupport);
LocalPlayer makeLocalProxy(Player player, LocalPlayerSupport localPlayerSupport);
}
| package IMPORT_0.vaguehope.morrigan.IMPORT_1;
import java.IMPORT_2.IMPORT_3;
import IMPORT_0.vaguehope.morrigan.IMPORT_4.IMPORT_5;
public interface CLASS_0 extends IMPORT_5<CLASS_1> {
IMPORT_3<CLASS_1> FUNC_0 ();
CLASS_1 FUNC_1 (CLASS_2 VAR_0);
CLASS_3 FUNC_2 (CLASS_2 VAR_1, CLASS_4 VAR_2);
CLASS_3 makeLocalProxy(CLASS_1 IMPORT_1, CLASS_4 VAR_2);
}
| 0.911809 | {'IMPORT_0': 'com', 'IMPORT_1': 'player', 'IMPORT_2': 'util', 'IMPORT_3': 'Collection', 'IMPORT_4': 'model', 'IMPORT_5': 'Register', 'CLASS_0': 'PlayerRegister', 'CLASS_1': 'Player', 'FUNC_0': 'getAll', 'FUNC_1': 'get', 'CLASS_2': 'String', 'VAR_0': 'id', 'CLASS_3': 'LocalPlayer', 'FUNC_2': 'makeLocal', 'VAR_1': 'name', 'CLASS_4': 'LocalPlayerSupport', 'VAR_2': 'localPlayerSupport'} | java | Texto | 44.00% |
/**
* @author Dennis Reedy
*/
public class LookupService {
private final ZContext context;
private final Map<UUID, ServiceRegistration> registrations = new ConcurrentHashMap<>();
private final ExecutorService registrationPool = Executors.newCachedThreadPool();
private final static Logger logger = LoggerFactory.getLogger(LookupService.class);
private static final BlockingQueue<ServiceRegistration> toPublish = new LinkedBlockingQueue<>();
private final AtomicBoolean keepAlive = new AtomicBoolean(true);
private final List<RunnableClosable> list = new ArrayList<>();
public LookupService() {
this(new ZContext(1));
}
public LookupService(ZContext context) {
this.context = context;
list.add(new RegistryPublisher());
list.add(new RegistryListener());
list.add(new ServiceLookup());
list.forEach(registrationPool::execute);
}
interface RunnableClosable extends Runnable {
void close();
}
public void terminate() {
keepAlive.set(false);
list.forEach(LookupService.RunnableClosable::close);
context.destroy();
registrationPool.shutdownNow();
}
private Status status(Result result) {
return status(result, null);
}
private Status status(Result result, String message) {
if(message==null)
return Status.newBuilder().setResult(result).build();
return Status.newBuilder().setResult(result).setStatus(message).build();
}
private ServiceRegistrationResult result(Status status) {
return result(status, null);
}
private ServiceRegistrationResult result(Status status, String uuid) {
if (uuid ==null)
return ServiceRegistrationResult.newBuilder().setStatus(status).build();
return ServiceRegistrationResult.newBuilder().setStatus(status).setUuid(uuid).build();
}
class ServiceRegistrationAction {
ServiceRegistration serviceRegistration;
String action;
}
class RegistryListener implements RunnableClosable {
ZMQ.Socket socket;
@Override public void run() {
socket = context.createSocket(ZMQ.REP);
socket.bind("tcp://*:" + DiscoveryConstants.SERVICE_REGISTRATION);
while (!Thread.currentThread().isInterrupted()) {
byte[] recv = socket.recv(0);
ServiceRegistration registration;
try {
registration = ServiceRegistration.parseFrom(recv);
UUID uuid = UUID.randomUUID();
registrations.put(uuid, registration);
Status status = status(Result.OKAY);
socket.send(ServiceRegistrationResult.newBuilder().setUuid(uuid.toString()).setStatus(status).build().toByteArray(), 0);
toPublish.offer(registration);
} catch (Exception e) {
String message = String.format("Failed de-serializing request: %s: %s",
e.getClass().getName(), e.getMessage());
logger.error("Failed de-serializing request", e);
try {
socket.send(result(status(Result.BAD_REQUEST, message)).toByteArray());
} catch (IOException e1) {
logger.error("Failed de-serializing request", e1);
}
}
}
//close();
}
public void close() {
context.destroySocket(socket);
}
}
class RegistryPublisher implements RunnableClosable {
ZMQ.Socket publisher;
@Override public void run() {
publisher = context.createSocket(ZMQ.PUB);
publisher.bind("tcp://*:" + DiscoveryConstants.SERVICE_REGISTRATION_PUB);
while (!Thread.currentThread().isInterrupted()) {
try {
ServiceRegistration serviceRegistration = toPublish.take();
publisher.sendMore(serviceRegistration.getGroupName());
publisher.send(serviceRegistration.toByteArray());
} catch (InterruptedException e) {
logger.trace("Interrupted taking ServiceRegistrations", e);
} catch (IOException e) {
logger.error("Could not create byte array to send", e);
}
}
}
public void close() {
context.destroySocket(publisher);
}
}
class ServiceLookup implements RunnableClosable {
ZMQ.Socket socket;
@Override public void run() {
socket = context.createSocket(ZMQ.REP);
socket.bind("tcp://*:" + DiscoveryConstants.SERVICE_LOOKUP);
ServiceRegistrationMatcher matcher = new ServiceRegistrationMatcher();
while (!Thread.currentThread().isInterrupted()) {
byte[] recv = socket.recv(0);
ServiceTemplate template;
try {
template = ServiceTemplate.parseFrom(recv);
List<ServiceRegistration> matched = new ArrayList<>();
matched.addAll(registrations.entrySet()
.stream()
.filter(entry -> matcher.match(template, entry.getValue()))
.map(Map.Entry<UUID, ServiceRegistration>::getValue)
.collect(Collectors.toList()));
Status status = status(Result.OKAY);
LookupResult result = LookupResult.newBuilder().setStatus(status).addServiceRegistrations(matched).build();
socket.send(result.toByteArray(), 0);
} catch (Exception e) {
String message = String.format("Failed de-serializing request: %s: %s",
e.getClass().getName(), e.getMessage());
logger.error("Failed de-serializing request", e);
try {
socket.send(result(status(Result.BAD_REQUEST, message)).toByteArray());
} catch (IOException e1) {
logger.error("Failed de-serializing request", e1);
}
}
}
//close();
}
public void close() {
context.destroySocket(socket);
}
}
} | /**
* @author Dennis Reedy
*/
public class CLASS_0 {
private final CLASS_1 context;
private final Map<UUID, ServiceRegistration> registrations = new ConcurrentHashMap<>();
private final ExecutorService VAR_1 = Executors.newCachedThreadPool();
private final static Logger logger = LoggerFactory.getLogger(CLASS_0.class);
private static final CLASS_2<ServiceRegistration> VAR_2 = new LinkedBlockingQueue<>();
private final AtomicBoolean keepAlive = new AtomicBoolean(true);
private final List<RunnableClosable> list = new ArrayList<>();
public CLASS_0() {
this(new CLASS_1(1));
}
public CLASS_0(CLASS_1 context) {
this.context = context;
list.add(new RegistryPublisher());
list.add(new RegistryListener());
list.add(new ServiceLookup());
list.forEach(VAR_1::execute);
}
interface RunnableClosable extends Runnable {
void close();
}
public void terminate() {
keepAlive.set(false);
list.forEach(VAR_0.RunnableClosable::close);
context.destroy();
VAR_1.shutdownNow();
}
private Status status(Result result) {
return status(result, null);
}
private Status status(Result result, CLASS_3 message) {
if(message==null)
return Status.newBuilder().setResult(result).build();
return Status.newBuilder().setResult(result).setStatus(message).build();
}
private ServiceRegistrationResult result(Status status) {
return result(status, null);
}
private ServiceRegistrationResult result(Status status, CLASS_3 uuid) {
if (uuid ==null)
return ServiceRegistrationResult.newBuilder().setStatus(status).build();
return ServiceRegistrationResult.newBuilder().setStatus(status).setUuid(uuid).build();
}
class ServiceRegistrationAction {
ServiceRegistration serviceRegistration;
CLASS_3 action;
}
class RegistryListener implements RunnableClosable {
ZMQ.Socket socket;
@Override public void run() {
socket = context.createSocket(ZMQ.REP);
socket.bind("tcp://*:" + DiscoveryConstants.SERVICE_REGISTRATION);
while (!Thread.currentThread().isInterrupted()) {
byte[] recv = socket.recv(0);
ServiceRegistration registration;
try {
registration = ServiceRegistration.parseFrom(recv);
UUID uuid = UUID.randomUUID();
registrations.put(uuid, registration);
Status status = status(Result.OKAY);
socket.send(ServiceRegistrationResult.newBuilder().setUuid(uuid.toString()).setStatus(status).build().toByteArray(), 0);
VAR_2.offer(registration);
} catch (Exception e) {
CLASS_3 message = VAR_3.format("Failed de-serializing request: %s: %s",
e.getClass().getName(), e.getMessage());
logger.error("Failed de-serializing request", e);
try {
socket.send(result(status(Result.BAD_REQUEST, message)).toByteArray());
} catch (IOException e1) {
logger.error("Failed de-serializing request", e1);
}
}
}
//close();
}
public void close() {
context.destroySocket(socket);
}
}
class RegistryPublisher implements RunnableClosable {
ZMQ.Socket publisher;
@Override public void run() {
publisher = context.createSocket(ZMQ.PUB);
publisher.bind("tcp://*:" + DiscoveryConstants.SERVICE_REGISTRATION_PUB);
while (!Thread.currentThread().isInterrupted()) {
try {
ServiceRegistration serviceRegistration = VAR_2.take();
publisher.sendMore(serviceRegistration.getGroupName());
publisher.send(serviceRegistration.toByteArray());
} catch (InterruptedException e) {
logger.trace("Interrupted taking ServiceRegistrations", e);
} catch (IOException e) {
logger.error("Could not create byte array to send", e);
}
}
}
public void close() {
context.destroySocket(publisher);
}
}
class ServiceLookup implements RunnableClosable {
ZMQ.Socket socket;
@Override public void run() {
socket = context.createSocket(ZMQ.REP);
socket.bind("tcp://*:" + DiscoveryConstants.SERVICE_LOOKUP);
ServiceRegistrationMatcher matcher = new ServiceRegistrationMatcher();
while (!Thread.currentThread().isInterrupted()) {
byte[] recv = socket.recv(0);
ServiceTemplate template;
try {
template = ServiceTemplate.parseFrom(recv);
List<ServiceRegistration> matched = new ArrayList<>();
matched.addAll(registrations.entrySet()
.stream()
.filter(entry -> matcher.match(template, entry.getValue()))
.map(Map.Entry<UUID, ServiceRegistration>::getValue)
.collect(Collectors.toList()));
Status status = status(Result.OKAY);
LookupResult result = LookupResult.newBuilder().setStatus(status).addServiceRegistrations(matched).build();
socket.send(result.toByteArray(), 0);
} catch (Exception e) {
CLASS_3 message = VAR_3.format("Failed de-serializing request: %s: %s",
e.getClass().getName(), e.getMessage());
logger.error("Failed de-serializing request", e);
try {
socket.send(result(status(Result.BAD_REQUEST, message)).toByteArray());
} catch (IOException e1) {
logger.error("Failed de-serializing request", e1);
}
}
}
//close();
}
public void close() {
context.destroySocket(socket);
}
}
} | 0.077797 | {'CLASS_0': 'LookupService', 'VAR_0': 'LookupService', 'CLASS_1': 'ZContext', 'VAR_1': 'registrationPool', 'CLASS_2': 'BlockingQueue', 'VAR_2': 'toPublish', 'CLASS_3': 'String', 'VAR_3': 'String'} | java | OOP | 4.94% |
/*
* Copyright (c) 2016 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package io.jsondb.tests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.File;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.google.common.io.Files;
import io.jsondb.JsonDBTemplate;
import io.jsondb.Util;
import io.jsondb.tests.model.PojoWithEnumFields;
import io.jsondb.tests.model.PojoWithEnumFields.Status;
/**
* @author <NAME>
* @version 1.0 06-Oct-2016
*/
public class PojoWithEnumFieldsTest {
private String dbFilesLocation = "src/test/resources/dbfiles/pojowithenumfieldsTests";
private File dbFilesFolder = new File(dbFilesLocation);
private File pojoWithEnumFieldsJson = new File(dbFilesFolder, "pojowithenumfields.json");
private JsonDBTemplate jsonDBTemplate = null;
@Before
public void setUp() throws Exception {
dbFilesFolder.mkdir();
Files.copy(new File("src/test/resources/dbfiles/pojowithenumfields.json"), pojoWithEnumFieldsJson);
jsonDBTemplate = new JsonDBTemplate(dbFilesLocation, "io.jsondb.tests.model");
}
@After
public void tearDown() throws Exception {
Util.delete(dbFilesFolder);
}
@Test
public void testFind() {
PojoWithEnumFields clazz = jsonDBTemplate.findById("0001", PojoWithEnumFields.class);
assertNotNull(clazz);
assertEquals(clazz.getStatus(), Status.CREATED);
}
@Test
public void testInsert() {
List<PojoWithEnumFields> clazzs = jsonDBTemplate.getCollection(PojoWithEnumFields.class);
int size = clazzs.size();
PojoWithEnumFields clazz = new PojoWithEnumFields();
clazz.setId("0010");
clazz.setStatus(Status.UPDATED);
jsonDBTemplate.insert(clazz);
clazzs = jsonDBTemplate.getCollection(PojoWithEnumFields.class);
assertNotNull(clazzs);
assertEquals(clazzs.size(), size+1);
}
}
| /*
* Copyright (c) 2016 <NAME>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
* deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
* sell copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package IMPORT_0.jsondb.tests;
import static org.junit.Assert.IMPORT_1;
import static org.junit.Assert.IMPORT_2;
import java.IMPORT_0.File;
import java.util.List;
import org.junit.IMPORT_3;
import org.junit.IMPORT_4;
import org.junit.Test;
import com.google.IMPORT_5.IMPORT_0.IMPORT_6;
import IMPORT_0.jsondb.IMPORT_7;
import IMPORT_0.jsondb.Util;
import IMPORT_0.jsondb.tests.model.PojoWithEnumFields;
import IMPORT_0.jsondb.tests.model.PojoWithEnumFields.Status;
/**
* @author <NAME>
* @version 1.0 06-Oct-2016
*/
public class PojoWithEnumFieldsTest {
private CLASS_0 VAR_0 = "src/test/resources/dbfiles/pojowithenumfieldsTests";
private File dbFilesFolder = new File(VAR_0);
private File VAR_1 = new File(dbFilesFolder, "pojowithenumfields.json");
private IMPORT_7 VAR_2 = null;
@IMPORT_4
public void setUp() throws Exception {
dbFilesFolder.FUNC_0();
IMPORT_6.copy(new File("src/test/resources/dbfiles/pojowithenumfields.json"), VAR_1);
VAR_2 = new IMPORT_7(VAR_0, "io.jsondb.tests.model");
}
@IMPORT_3
public void tearDown() throws Exception {
Util.FUNC_1(dbFilesFolder);
}
@Test
public void testFind() {
PojoWithEnumFields clazz = VAR_2.findById("0001", PojoWithEnumFields.class);
IMPORT_2(clazz);
IMPORT_1(clazz.FUNC_2(), Status.VAR_3);
}
@Test
public void testInsert() {
List<PojoWithEnumFields> clazzs = VAR_2.getCollection(PojoWithEnumFields.class);
int size = clazzs.size();
PojoWithEnumFields clazz = new PojoWithEnumFields();
clazz.FUNC_3("0010");
clazz.FUNC_4(Status.UPDATED);
VAR_2.FUNC_5(clazz);
clazzs = VAR_2.getCollection(PojoWithEnumFields.class);
IMPORT_2(clazzs);
IMPORT_1(clazzs.size(), size+1);
}
}
| 0.376949 | {'IMPORT_0': 'io', 'IMPORT_1': 'assertEquals', 'IMPORT_2': 'assertNotNull', 'IMPORT_3': 'After', 'IMPORT_4': 'Before', 'IMPORT_5': 'common', 'IMPORT_6': 'Files', 'IMPORT_7': 'JsonDBTemplate', 'CLASS_0': 'String', 'VAR_0': 'dbFilesLocation', 'VAR_1': 'pojoWithEnumFieldsJson', 'VAR_2': 'jsonDBTemplate', 'FUNC_0': 'mkdir', 'FUNC_1': 'delete', 'FUNC_2': 'getStatus', 'VAR_3': 'CREATED', 'FUNC_3': 'setId', 'FUNC_4': 'setStatus', 'FUNC_5': 'insert'} | java | Hibrido | 70.35% |
/**
* Acquires the lock.
*
* <p>If the lock is not available then the current thread becomes
* disabled for thread scheduling purposes and lies dormant until the
* lock has been acquired.
*
* <p><b>Implementation Considerations</b>
*
* <p>A {@code Lock} implementation may be able to detect erroneous use
* of the lock, such as an invocation that would cause deadlock, and
* may throw an (unchecked) exception in such circumstances. The
* circumstances and the exception type must be documented by that
* {@code Lock} implementation.
*/
@Override
public void lock(String namespace) throws DistributedLockException {
contextExceptionNotSet();
this.distributedLockThreadLocal.get().lock(namespace);
} | /**
* Acquires the lock.
*
* <p>If the lock is not available then the current thread becomes
* disabled for thread scheduling purposes and lies dormant until the
* lock has been acquired.
*
* <p><b>Implementation Considerations</b>
*
* <p>A {@code Lock} implementation may be able to detect erroneous use
* of the lock, such as an invocation that would cause deadlock, and
* may throw an (unchecked) exception in such circumstances. The
* circumstances and the exception type must be documented by that
* {@code Lock} implementation.
*/
@VAR_0
public void lock(String VAR_1) throws CLASS_0 {
FUNC_0();
this.VAR_2.FUNC_1().lock(VAR_1);
} | 0.73099 | {'VAR_0': 'Override', 'VAR_1': 'namespace', 'CLASS_0': 'DistributedLockException', 'FUNC_0': 'contextExceptionNotSet', 'VAR_2': 'distributedLockThreadLocal', 'FUNC_1': 'get'} | java | Texto | 33.64% |
package be.wegenenverkeer.atomium.store;
import be.wegenenverkeer.atomium.api.Event;
import java.util.List;
/**
* Created by <NAME>, Geovise BVBA on 10/12/16.
*/
public interface GetEventsOp<T> extends JdbcOp<List<Event<T>>> {
void setRange(long startNum, long size);
}
| package be.wegenenverkeer.IMPORT_0.store;
import be.wegenenverkeer.IMPORT_0.api.Event;
import java.util.List;
/**
* Created by <NAME>, Geovise BVBA on 10/12/16.
*/
public interface GetEventsOp<T> extends CLASS_0<List<Event<T>>> {
void setRange(long VAR_0, long size);
}
| 0.297974 | {'IMPORT_0': 'atomium', 'CLASS_0': 'JdbcOp', 'VAR_0': 'startNum'} | java | Texto | 77.50% |
package com.jidda.reactorUtils.join;
import com.jidda.reactorUtils.InnerProducer;
import reactor.core.Disposable;
public interface ConditionalJoinParent<R> extends InnerProducer<R> {
void innerError(Throwable ex);
void innerComplete(Disposable sender);
void innerValue(Integer type,Object value);
}
| package com.jidda.reactorUtils.join;
import com.jidda.reactorUtils.InnerProducer;
import IMPORT_0.IMPORT_1.IMPORT_2;
public interface ConditionalJoinParent<R> extends InnerProducer<R> {
void innerError(Throwable VAR_0);
void innerComplete(IMPORT_2 sender);
void innerValue(Integer type,Object value);
}
| 0.144035 | {'IMPORT_0': 'reactor', 'IMPORT_1': 'core', 'IMPORT_2': 'Disposable', 'VAR_0': 'ex'} | java | Texto | 51.16% |
package com.xhhf.shaika.util;
/**
* Created by Administrator on 2016/11/15 0015.
*/
public class MyResource {
// public static final String HOME_TOP_URL = "http://192.168.249.138/app/block/indexTop";
public static final String BASE_URL = "http://172.16.17.32";
public static final String HOME_TOP_URL = BASE_URL + "/app/block/indexTop";
}
| package IMPORT_0.xhhf.shaika.util;
/**
* Created by Administrator on 2016/11/15 0015.
*/
public class MyResource {
// public static final String HOME_TOP_URL = "http://192.168.249.138/app/block/indexTop";
public static final String BASE_URL = "http://172.16.17.32";
public static final String HOME_TOP_URL = BASE_URL + "/app/block/indexTop";
}
| 0.555255 | {'IMPORT_0': 'com'} | java | OOP | 100.00% |
/**
* Computes the client and server's common session 'Key' according to the standard routine: Key = H(S)
*
* @see <a href="https://tools.ietf.org/html/rfc5054">Specification: RFC 5054</a>
* @see <a href="https://tools.ietf.org/html/rfc2945">Specification: RFC 2945</a>
* @see <a href="https://en.wikipedia.org/wiki/Secure_Remote_Password_protocol">Secure Remote Password protocol</a>
*
* @param digest The Digest used as the hashing function 'H'
* @param N The safe prime parameter 'N' (a prime of the form N=2q+1, where q is also prime)
* @param S The client or server's calculated secret (pre-master secret)
* @return the resulting client and server's common 'Key'
*/
static BigInteger computeSessionKey(DigestService digest, BigInteger N, BigInteger S) {
Validate.notNull(digest);
Validate.notNull(N);
Validate.notNull(S);
final int padLength = calculatePadLength(N);
return
toBigInteger(
digest.digest(
padLeft(toUnsignedByteArray(S), padLength, PAD_ZERO)));
} | /**
* Computes the client and server's common session 'Key' according to the standard routine: Key = H(S)
*
* @see <a href="https://tools.ietf.org/html/rfc5054">Specification: RFC 5054</a>
* @see <a href="https://tools.ietf.org/html/rfc2945">Specification: RFC 2945</a>
* @see <a href="https://en.wikipedia.org/wiki/Secure_Remote_Password_protocol">Secure Remote Password protocol</a>
*
* @param digest The Digest used as the hashing function 'H'
* @param N The safe prime parameter 'N' (a prime of the form N=2q+1, where q is also prime)
* @param S The client or server's calculated secret (pre-master secret)
* @return the resulting client and server's common 'Key'
*/
static BigInteger computeSessionKey(DigestService digest, BigInteger N, BigInteger S) {
Validate.notNull(digest);
Validate.notNull(N);
Validate.notNull(S);
final int padLength = calculatePadLength(N);
return
toBigInteger(
digest.digest(
padLeft(toUnsignedByteArray(S), padLength, PAD_ZERO)));
} | 0.111981 | {} | java | Procedural | 91.72% |
package mil.nga.giat.geowave.adapter.raster.adapter.merge;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import mil.nga.giat.geowave.core.index.ByteArrayUtils;
import mil.nga.giat.geowave.core.index.PersistenceUtils;
import mil.nga.giat.geowave.datastore.accumulo.IteratorConfig;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.iterators.IteratorUtil.IteratorScope;
public class RasterTileCombinerConfig extends
IteratorConfig
{
public RasterTileCombinerConfig(
final IteratorSetting iteratorSettings,
final EnumSet<IteratorScope> scopes ) {
super(
iteratorSettings,
scopes);
}
@Override
public String mergeOption(
final String optionKey,
final String currentValue,
final String nextValue ) {
if ((currentValue == null) || currentValue.trim().isEmpty()) {
return nextValue;
}
else if ((nextValue == null) || nextValue.trim().isEmpty()) {
return currentValue;
}
if (RasterTileCombinerHelper.MERGE_STRATEGY_KEY.equals(optionKey)) {
final byte[] currentStrategyBytes = ByteArrayUtils.byteArrayFromString(currentValue);
final byte[] nextStrategyBytes = ByteArrayUtils.byteArrayFromString(nextValue);
final RootMergeStrategy currentStrategy = PersistenceUtils.fromBinary(
currentStrategyBytes,
RootMergeStrategy.class);
final RootMergeStrategy nextStrategy = PersistenceUtils.fromBinary(
nextStrategyBytes,
RootMergeStrategy.class);
currentStrategy.merge(nextStrategy);
return ByteArrayUtils.byteArrayToString(PersistenceUtils.toBinary(currentStrategy));
}
else if (RasterTileCombiner.COLUMNS_KEY.equals(optionKey)) {
final String encodedColumns = currentValue;
final Set<String> nextColumns = new HashSet<String>();
for (final String column : nextValue.split(",")) {
nextColumns.add(column);
}
final StringBuffer str = new StringBuffer(
nextValue);
for (final String column : encodedColumns.split(",")) {
if (!nextColumns.contains(column)) {
str.append(",");
str.append(column);
}
}
return str.toString();
}
return super.mergeOption(
optionKey,
currentValue,
nextValue);
}
}
| package IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3.adapter.IMPORT_4.adapter.IMPORT_5;
import IMPORT_6.util.IMPORT_7;
import IMPORT_6.util.IMPORT_8;
import IMPORT_6.util.IMPORT_9;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3.IMPORT_10.IMPORT_11.IMPORT_12;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3.IMPORT_10.IMPORT_11.IMPORT_13;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3.IMPORT_14.IMPORT_15.IMPORT_16;
import IMPORT_17.IMPORT_18.IMPORT_15.IMPORT_10.IMPORT_19.IMPORT_20;
import IMPORT_17.IMPORT_18.IMPORT_15.IMPORT_10.IMPORT_21.IMPORT_22.IteratorScope;
public class RasterTileCombinerConfig extends
IMPORT_16
{
public RasterTileCombinerConfig(
final IMPORT_20 VAR_0,
final IMPORT_7<IteratorScope> VAR_1 ) {
super(
VAR_0,
VAR_1);
}
@VAR_2
public CLASS_0 FUNC_0(
final CLASS_0 VAR_3,
final CLASS_0 VAR_4,
final CLASS_0 VAR_5 ) {
if ((VAR_4 == null) || VAR_4.trim().FUNC_1()) {
return VAR_5;
}
else if ((VAR_5 == null) || VAR_5.trim().FUNC_1()) {
return VAR_4;
}
if (VAR_6.VAR_7.FUNC_2(VAR_3)) {
final byte[] VAR_8 = IMPORT_12.byteArrayFromString(VAR_4);
final byte[] VAR_9 = IMPORT_12.byteArrayFromString(VAR_5);
final RootMergeStrategy VAR_10 = IMPORT_13.FUNC_3(
VAR_8,
RootMergeStrategy.class);
final RootMergeStrategy VAR_11 = IMPORT_13.FUNC_3(
VAR_9,
RootMergeStrategy.class);
VAR_10.IMPORT_5(VAR_11);
return IMPORT_12.FUNC_4(IMPORT_13.toBinary(VAR_10));
}
else if (VAR_12.VAR_13.FUNC_2(VAR_3)) {
final CLASS_0 VAR_14 = VAR_4;
final IMPORT_9<CLASS_0> VAR_15 = new IMPORT_8<CLASS_0>();
for (final CLASS_0 VAR_16 : VAR_5.FUNC_5(",")) {
VAR_15.FUNC_6(VAR_16);
}
final CLASS_1 VAR_17 = new CLASS_1(
VAR_5);
for (final CLASS_0 VAR_16 : VAR_14.FUNC_5(",")) {
if (!VAR_15.FUNC_7(VAR_16)) {
VAR_17.FUNC_8(",");
VAR_17.FUNC_8(VAR_16);
}
}
return VAR_17.FUNC_9();
}
return super.FUNC_0(
VAR_3,
VAR_4,
VAR_5);
}
}
| 0.854055 | {'IMPORT_0': 'mil', 'IMPORT_1': 'nga', 'IMPORT_2': 'giat', 'IMPORT_3': 'geowave', 'IMPORT_4': 'raster', 'IMPORT_5': 'merge', 'IMPORT_6': 'java', 'IMPORT_7': 'EnumSet', 'IMPORT_8': 'HashSet', 'IMPORT_9': 'Set', 'IMPORT_10': 'core', 'IMPORT_11': 'index', 'IMPORT_12': 'ByteArrayUtils', 'IMPORT_13': 'PersistenceUtils', 'IMPORT_14': 'datastore', 'IMPORT_15': 'accumulo', 'IMPORT_16': 'IteratorConfig', 'IMPORT_17': 'org', 'IMPORT_18': 'apache', 'IMPORT_19': 'client', 'IMPORT_20': 'IteratorSetting', 'IMPORT_21': 'iterators', 'IMPORT_22': 'IteratorUtil', 'VAR_0': 'iteratorSettings', 'VAR_1': 'scopes', 'VAR_2': 'Override', 'CLASS_0': 'String', 'FUNC_0': 'mergeOption', 'VAR_3': 'optionKey', 'VAR_4': 'currentValue', 'VAR_5': 'nextValue', 'FUNC_1': 'isEmpty', 'VAR_6': 'RasterTileCombinerHelper', 'VAR_7': 'MERGE_STRATEGY_KEY', 'FUNC_2': 'equals', 'VAR_8': 'currentStrategyBytes', 'VAR_9': 'nextStrategyBytes', 'VAR_10': 'currentStrategy', 'FUNC_3': 'fromBinary', 'VAR_11': 'nextStrategy', 'FUNC_4': 'byteArrayToString', 'VAR_12': 'RasterTileCombiner', 'VAR_13': 'COLUMNS_KEY', 'VAR_14': 'encodedColumns', 'VAR_15': 'nextColumns', 'VAR_16': 'column', 'FUNC_5': 'split', 'FUNC_6': 'add', 'CLASS_1': 'StringBuffer', 'VAR_17': 'str', 'FUNC_7': 'contains', 'FUNC_8': 'append', 'FUNC_9': 'toString'} | java | OOP | 34.92% |
// "Replace with 'computeIfAbsent' method call" "true"
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class Test {
interface Shift {}
void foo(Map<String, List<Shift>> dayOfWeekAndShiftTypeToShiftListMap, String key){
List<Shift> dayOfWeekAndShiftTypeToShiftList = dayOfWeekAndShiftTypeToShiftListMap.computeIfAbsent(key, k -> new ArrayList<>((6) / 7));
}
} | // "Replace with 'computeIfAbsent' method call" "true"
import java.util.IMPORT_0;
import java.util.List;
import java.util.Map;
public class CLASS_0 {
interface Shift {}
void FUNC_0(Map<CLASS_1, List<Shift>> dayOfWeekAndShiftTypeToShiftListMap, CLASS_1 key){
List<Shift> dayOfWeekAndShiftTypeToShiftList = dayOfWeekAndShiftTypeToShiftListMap.computeIfAbsent(key, VAR_0 -> new IMPORT_0<>((6) / 7));
}
} | 0.355222 | {'IMPORT_0': 'ArrayList', 'CLASS_0': 'Test', 'FUNC_0': 'foo', 'CLASS_1': 'String', 'VAR_0': 'k'} | java | OOP | 87.76% |
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: Theta.proto
package wallet.core.jni.proto;
public final class Theta {
private Theta() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistryLite registry) {
}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
registerAllExtensions(
(com.google.protobuf.ExtensionRegistryLite) registry);
}
public interface SigningInputOrBuilder extends
// @@protoc_insertion_point(interface_extends:TW.Theta.Proto.SigningInput)
com.google.protobuf.MessageOrBuilder {
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
java.lang.String getChainId();
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
com.google.protobuf.ByteString
getChainIdBytes();
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
java.lang.String getToAddress();
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
com.google.protobuf.ByteString
getToAddressBytes();
/**
* <pre>
*/ Theta token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes theta_amount = 3;</code>
*/
com.google.protobuf.ByteString getThetaAmount();
/**
* <pre>
*/ TFuel token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes tfuel_amount = 4;</code>
*/
com.google.protobuf.ByteString getTfuelAmount();
/**
* <pre>
*/ Sequence number of the transaction for the sender address
* </pre>
*
* <code>uint64 sequence = 5;</code>
*/
long getSequence();
/**
* <pre>
*/ Fee amount in TFuel wei for the transaction (256-bit number)
* </pre>
*
* <code>bytes fee = 6;</code>
*/
com.google.protobuf.ByteString getFee();
/**
* <pre>
*/ Private key
* </pre>
*
* <code>bytes private_key = 7;</code>
*/
com.google.protobuf.ByteString getPrivateKey();
}
/**
* <pre>
*/ Input data necessary to create a signed transaction
* </pre>
*
* Protobuf type {@code TW.Theta.Proto.SigningInput}
*/
public static final class SigningInput extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:TW.Theta.Proto.SigningInput)
SigningInputOrBuilder {
private static final long serialVersionUID = 0L;
// Use SigningInput.newBuilder() to construct.
private SigningInput(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private SigningInput() {
chainId_ = "";
toAddress_ = "";
thetaAmount_ = com.google.protobuf.ByteString.EMPTY;
tfuelAmount_ = com.google.protobuf.ByteString.EMPTY;
fee_ = com.google.protobuf.ByteString.EMPTY;
privateKey_ = com.google.protobuf.ByteString.EMPTY;
}
@java.lang.Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
private SigningInput(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
if (extensionRegistry == null) {
throw new java.lang.NullPointerException();
}
int mutable_bitField0_ = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
case 10: {
java.lang.String s = input.readStringRequireUtf8();
chainId_ = s;
break;
}
case 18: {
java.lang.String s = input.readStringRequireUtf8();
toAddress_ = s;
break;
}
case 26: {
thetaAmount_ = input.readBytes();
break;
}
case 34: {
tfuelAmount_ = input.readBytes();
break;
}
case 40: {
sequence_ = input.readUInt64();
break;
}
case 50: {
fee_ = input.readBytes();
break;
}
case 58: {
privateKey_ = input.readBytes();
break;
}
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
done = true;
}
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningInput_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningInput_fieldAccessorTable
.ensureFieldAccessorsInitialized(
wallet.core.jni.proto.Theta.SigningInput.class, wallet.core.jni.proto.Theta.SigningInput.Builder.class);
}
public static final int CHAIN_ID_FIELD_NUMBER = 1;
private volatile java.lang.Object chainId_;
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
public java.lang.String getChainId() {
java.lang.Object ref = chainId_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
chainId_ = s;
return s;
}
}
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
public com.google.protobuf.ByteString
getChainIdBytes() {
java.lang.Object ref = chainId_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
chainId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int TO_ADDRESS_FIELD_NUMBER = 2;
private volatile java.lang.Object toAddress_;
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
public java.lang.String getToAddress() {
java.lang.Object ref = toAddress_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
toAddress_ = s;
return s;
}
}
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
public com.google.protobuf.ByteString
getToAddressBytes() {
java.lang.Object ref = toAddress_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
toAddress_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int THETA_AMOUNT_FIELD_NUMBER = 3;
private com.google.protobuf.ByteString thetaAmount_;
/**
* <pre>
*/ Theta token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes theta_amount = 3;</code>
*/
public com.google.protobuf.ByteString getThetaAmount() {
return thetaAmount_;
}
public static final int TFUEL_AMOUNT_FIELD_NUMBER = 4;
private com.google.protobuf.ByteString tfuelAmount_;
/**
* <pre>
*/ TFuel token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes tfuel_amount = 4;</code>
*/
public com.google.protobuf.ByteString getTfuelAmount() {
return tfuelAmount_;
}
public static final int SEQUENCE_FIELD_NUMBER = 5;
private long sequence_;
/**
* <pre>
*/ Sequence number of the transaction for the sender address
* </pre>
*
* <code>uint64 sequence = 5;</code>
*/
public long getSequence() {
return sequence_;
}
public static final int FEE_FIELD_NUMBER = 6;
private com.google.protobuf.ByteString fee_;
/**
* <pre>
*/ Fee amount in TFuel wei for the transaction (256-bit number)
* </pre>
*
* <code>bytes fee = 6;</code>
*/
public com.google.protobuf.ByteString getFee() {
return fee_;
}
public static final int PRIVATE_KEY_FIELD_NUMBER = 7;
private com.google.protobuf.ByteString privateKey_;
/**
* <pre>
*/ Private key
* </pre>
*
* <code>bytes private_key = 7;</code>
*/
public com.google.protobuf.ByteString getPrivateKey() {
return privateKey_;
}
private byte memoizedIsInitialized = -1;
@java.lang.Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
@java.lang.Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (!getChainIdBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, chainId_);
}
if (!getToAddressBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, toAddress_);
}
if (!thetaAmount_.isEmpty()) {
output.writeBytes(3, thetaAmount_);
}
if (!tfuelAmount_.isEmpty()) {
output.writeBytes(4, tfuelAmount_);
}
if (sequence_ != 0L) {
output.writeUInt64(5, sequence_);
}
if (!fee_.isEmpty()) {
output.writeBytes(6, fee_);
}
if (!privateKey_.isEmpty()) {
output.writeBytes(7, privateKey_);
}
unknownFields.writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!getChainIdBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, chainId_);
}
if (!getToAddressBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, toAddress_);
}
if (!thetaAmount_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(3, thetaAmount_);
}
if (!tfuelAmount_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(4, tfuelAmount_);
}
if (sequence_ != 0L) {
size += com.google.protobuf.CodedOutputStream
.computeUInt64Size(5, sequence_);
}
if (!fee_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(6, fee_);
}
if (!privateKey_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(7, privateKey_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
}
@java.lang.Override
public boolean equals(final java.lang.Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof wallet.core.jni.proto.Theta.SigningInput)) {
return super.equals(obj);
}
wallet.core.jni.proto.Theta.SigningInput other = (wallet.core.jni.proto.Theta.SigningInput) obj;
if (!getChainId()
.equals(other.getChainId())) return false;
if (!getToAddress()
.equals(other.getToAddress())) return false;
if (!getThetaAmount()
.equals(other.getThetaAmount())) return false;
if (!getTfuelAmount()
.equals(other.getTfuelAmount())) return false;
if (getSequence()
!= other.getSequence()) return false;
if (!getFee()
.equals(other.getFee())) return false;
if (!getPrivateKey()
.equals(other.getPrivateKey())) return false;
if (!unknownFields.equals(other.unknownFields)) return false;
return true;
}
@java.lang.Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + CHAIN_ID_FIELD_NUMBER;
hash = (53 * hash) + getChainId().hashCode();
hash = (37 * hash) + TO_ADDRESS_FIELD_NUMBER;
hash = (53 * hash) + getToAddress().hashCode();
hash = (37 * hash) + THETA_AMOUNT_FIELD_NUMBER;
hash = (53 * hash) + getThetaAmount().hashCode();
hash = (37 * hash) + TFUEL_AMOUNT_FIELD_NUMBER;
hash = (53 * hash) + getTfuelAmount().hashCode();
hash = (37 * hash) + SEQUENCE_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
getSequence());
hash = (37 * hash) + FEE_FIELD_NUMBER;
hash = (53 * hash) + getFee().hashCode();
hash = (37 * hash) + PRIVATE_KEY_FIELD_NUMBER;
hash = (53 * hash) + getPrivateKey().hashCode();
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningInput parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static wallet.core.jni.proto.Theta.SigningInput parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
@java.lang.Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(wallet.core.jni.proto.Theta.SigningInput prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
@java.lang.Override
public Builder toBuilder() {
return this == DEFAULT_INSTANCE
? new Builder() : new Builder().mergeFrom(this);
}
@java.lang.Override
protected Builder newBuilderForType(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* <pre>
*/ Input data necessary to create a signed transaction
* </pre>
*
* Protobuf type {@code TW.Theta.Proto.SigningInput}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:TW.Theta.Proto.SigningInput)
wallet.core.jni.proto.Theta.SigningInputOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningInput_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningInput_fieldAccessorTable
.ensureFieldAccessorsInitialized(
wallet.core.jni.proto.Theta.SigningInput.class, wallet.core.jni.proto.Theta.SigningInput.Builder.class);
}
// Construct using wallet.core.jni.proto.Theta.SigningInput.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3
.alwaysUseFieldBuilders) {
}
}
@java.lang.Override
public Builder clear() {
super.clear();
chainId_ = "";
toAddress_ = "";
thetaAmount_ = com.google.protobuf.ByteString.EMPTY;
tfuelAmount_ = com.google.protobuf.ByteString.EMPTY;
sequence_ = 0L;
fee_ = com.google.protobuf.ByteString.EMPTY;
privateKey_ = com.google.protobuf.ByteString.EMPTY;
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningInput_descriptor;
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningInput getDefaultInstanceForType() {
return wallet.core.jni.proto.Theta.SigningInput.getDefaultInstance();
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningInput build() {
wallet.core.jni.proto.Theta.SigningInput result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningInput buildPartial() {
wallet.core.jni.proto.Theta.SigningInput result = new wallet.core.jni.proto.Theta.SigningInput(this);
result.chainId_ = chainId_;
result.toAddress_ = toAddress_;
result.thetaAmount_ = thetaAmount_;
result.tfuelAmount_ = tfuelAmount_;
result.sequence_ = sequence_;
result.fee_ = fee_;
result.privateKey_ = privateKey_;
onBuilt();
return result;
}
@java.lang.Override
public Builder clone() {
return super.clone();
}
@java.lang.Override
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
java.lang.Object value) {
return super.setField(field, value);
}
@java.lang.Override
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return super.clearField(field);
}
@java.lang.Override
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@java.lang.Override
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, java.lang.Object value) {
return super.setRepeatedField(field, index, value);
}
@java.lang.Override
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
java.lang.Object value) {
return super.addRepeatedField(field, value);
}
@java.lang.Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof wallet.core.jni.proto.Theta.SigningInput) {
return mergeFrom((wallet.core.jni.proto.Theta.SigningInput)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(wallet.core.jni.proto.Theta.SigningInput other) {
if (other == wallet.core.jni.proto.Theta.SigningInput.getDefaultInstance()) return this;
if (!other.getChainId().isEmpty()) {
chainId_ = other.chainId_;
onChanged();
}
if (!other.getToAddress().isEmpty()) {
toAddress_ = other.toAddress_;
onChanged();
}
if (other.getThetaAmount() != com.google.protobuf.ByteString.EMPTY) {
setThetaAmount(other.getThetaAmount());
}
if (other.getTfuelAmount() != com.google.protobuf.ByteString.EMPTY) {
setTfuelAmount(other.getTfuelAmount());
}
if (other.getSequence() != 0L) {
setSequence(other.getSequence());
}
if (other.getFee() != com.google.protobuf.ByteString.EMPTY) {
setFee(other.getFee());
}
if (other.getPrivateKey() != com.google.protobuf.ByteString.EMPTY) {
setPrivateKey(other.getPrivateKey());
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
}
@java.lang.Override
public final boolean isInitialized() {
return true;
}
@java.lang.Override
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
wallet.core.jni.proto.Theta.SigningInput parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (wallet.core.jni.proto.Theta.SigningInput) e.getUnfinishedMessage();
throw e.unwrapIOException();
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private java.lang.Object chainId_ = "";
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
public java.lang.String getChainId() {
java.lang.Object ref = chainId_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
chainId_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
public com.google.protobuf.ByteString
getChainIdBytes() {
java.lang.Object ref = chainId_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
chainId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
public Builder setChainId(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
chainId_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
public Builder clearChainId() {
chainId_ = getDefaultInstance().getChainId();
onChanged();
return this;
}
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
public Builder setChainIdBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
chainId_ = value;
onChanged();
return this;
}
private java.lang.Object toAddress_ = "";
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
public java.lang.String getToAddress() {
java.lang.Object ref = toAddress_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
toAddress_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
public com.google.protobuf.ByteString
getToAddressBytes() {
java.lang.Object ref = toAddress_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(java.lang.String) ref);
toAddress_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
public Builder setToAddress(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
toAddress_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
public Builder clearToAddress() {
toAddress_ = getDefaultInstance().getToAddress();
onChanged();
return this;
}
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
public Builder setToAddressBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
toAddress_ = value;
onChanged();
return this;
}
private com.google.protobuf.ByteString thetaAmount_ = com.google.protobuf.ByteString.EMPTY;
/**
* <pre>
*/ Theta token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes theta_amount = 3;</code>
*/
public com.google.protobuf.ByteString getThetaAmount() {
return thetaAmount_;
}
/**
* <pre>
*/ Theta token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes theta_amount = 3;</code>
*/
public Builder setThetaAmount(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
thetaAmount_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Theta token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes theta_amount = 3;</code>
*/
public Builder clearThetaAmount() {
thetaAmount_ = getDefaultInstance().getThetaAmount();
onChanged();
return this;
}
private com.google.protobuf.ByteString tfuelAmount_ = com.google.protobuf.ByteString.EMPTY;
/**
* <pre>
*/ TFuel token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes tfuel_amount = 4;</code>
*/
public com.google.protobuf.ByteString getTfuelAmount() {
return tfuelAmount_;
}
/**
* <pre>
*/ TFuel token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes tfuel_amount = 4;</code>
*/
public Builder setTfuelAmount(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
tfuelAmount_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ TFuel token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes tfuel_amount = 4;</code>
*/
public Builder clearTfuelAmount() {
tfuelAmount_ = getDefaultInstance().getTfuelAmount();
onChanged();
return this;
}
private long sequence_ ;
/**
* <pre>
*/ Sequence number of the transaction for the sender address
* </pre>
*
* <code>uint64 sequence = 5;</code>
*/
public long getSequence() {
return sequence_;
}
/**
* <pre>
*/ Sequence number of the transaction for the sender address
* </pre>
*
* <code>uint64 sequence = 5;</code>
*/
public Builder setSequence(long value) {
sequence_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Sequence number of the transaction for the sender address
* </pre>
*
* <code>uint64 sequence = 5;</code>
*/
public Builder clearSequence() {
sequence_ = 0L;
onChanged();
return this;
}
private com.google.protobuf.ByteString fee_ = com.google.protobuf.ByteString.EMPTY;
/**
* <pre>
*/ Fee amount in TFuel wei for the transaction (256-bit number)
* </pre>
*
* <code>bytes fee = 6;</code>
*/
public com.google.protobuf.ByteString getFee() {
return fee_;
}
/**
* <pre>
*/ Fee amount in TFuel wei for the transaction (256-bit number)
* </pre>
*
* <code>bytes fee = 6;</code>
*/
public Builder setFee(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
fee_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Fee amount in TFuel wei for the transaction (256-bit number)
* </pre>
*
* <code>bytes fee = 6;</code>
*/
public Builder clearFee() {
fee_ = getDefaultInstance().getFee();
onChanged();
return this;
}
private com.google.protobuf.ByteString privateKey_ = com.google.protobuf.ByteString.EMPTY;
/**
* <pre>
*/ Private key
* </pre>
*
* <code>bytes private_key = 7;</code>
*/
public com.google.protobuf.ByteString getPrivateKey() {
return privateKey_;
}
/**
* <pre>
*/ Private key
* </pre>
*
* <code>bytes private_key = 7;</code>
*/
public Builder setPrivateKey(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
privateKey_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Private key
* </pre>
*
* <code>bytes private_key = 7;</code>
*/
public Builder clearPrivateKey() {
privateKey_ = getDefaultInstance().getPrivateKey();
onChanged();
return this;
}
@java.lang.Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
@java.lang.Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:TW.Theta.Proto.SigningInput)
}
// @@protoc_insertion_point(class_scope:TW.Theta.Proto.SigningInput)
private static final wallet.core.jni.proto.Theta.SigningInput DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new wallet.core.jni.proto.Theta.SigningInput();
}
public static wallet.core.jni.proto.Theta.SigningInput getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<SigningInput>
PARSER = new com.google.protobuf.AbstractParser<SigningInput>() {
@java.lang.Override
public SigningInput parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new SigningInput(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<SigningInput> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<SigningInput> getParserForType() {
return PARSER;
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningInput getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
public interface SigningOutputOrBuilder extends
// @@protoc_insertion_point(interface_extends:TW.Theta.Proto.SigningOutput)
com.google.protobuf.MessageOrBuilder {
/**
* <pre>
*/ Signed and encoded transaction bytes
* </pre>
*
* <code>bytes encoded = 1;</code>
*/
com.google.protobuf.ByteString getEncoded();
/**
* <pre>
*/ Signature
* </pre>
*
* <code>bytes signature = 2;</code>
*/
com.google.protobuf.ByteString getSignature();
}
/**
* <pre>
*/ Transaction signing output
* </pre>
*
* Protobuf type {@code TW.Theta.Proto.SigningOutput}
*/
public static final class SigningOutput extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:TW.Theta.Proto.SigningOutput)
SigningOutputOrBuilder {
private static final long serialVersionUID = 0L;
// Use SigningOutput.newBuilder() to construct.
private SigningOutput(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private SigningOutput() {
encoded_ = com.google.protobuf.ByteString.EMPTY;
signature_ = com.google.protobuf.ByteString.EMPTY;
}
@java.lang.Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
private SigningOutput(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
if (extensionRegistry == null) {
throw new java.lang.NullPointerException();
}
int mutable_bitField0_ = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
case 10: {
encoded_ = input.readBytes();
break;
}
case 18: {
signature_ = input.readBytes();
break;
}
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
done = true;
}
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningOutput_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningOutput_fieldAccessorTable
.ensureFieldAccessorsInitialized(
wallet.core.jni.proto.Theta.SigningOutput.class, wallet.core.jni.proto.Theta.SigningOutput.Builder.class);
}
public static final int ENCODED_FIELD_NUMBER = 1;
private com.google.protobuf.ByteString encoded_;
/**
* <pre>
*/ Signed and encoded transaction bytes
* </pre>
*
* <code>bytes encoded = 1;</code>
*/
public com.google.protobuf.ByteString getEncoded() {
return encoded_;
}
public static final int SIGNATURE_FIELD_NUMBER = 2;
private com.google.protobuf.ByteString signature_;
/**
* <pre>
*/ Signature
* </pre>
*
* <code>bytes signature = 2;</code>
*/
public com.google.protobuf.ByteString getSignature() {
return signature_;
}
private byte memoizedIsInitialized = -1;
@java.lang.Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
@java.lang.Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (!encoded_.isEmpty()) {
output.writeBytes(1, encoded_);
}
if (!signature_.isEmpty()) {
output.writeBytes(2, signature_);
}
unknownFields.writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!encoded_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(1, encoded_);
}
if (!signature_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(2, signature_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
}
@java.lang.Override
public boolean equals(final java.lang.Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof wallet.core.jni.proto.Theta.SigningOutput)) {
return super.equals(obj);
}
wallet.core.jni.proto.Theta.SigningOutput other = (wallet.core.jni.proto.Theta.SigningOutput) obj;
if (!getEncoded()
.equals(other.getEncoded())) return false;
if (!getSignature()
.equals(other.getSignature())) return false;
if (!unknownFields.equals(other.unknownFields)) return false;
return true;
}
@java.lang.Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + ENCODED_FIELD_NUMBER;
hash = (53 * hash) + getEncoded().hashCode();
hash = (37 * hash) + SIGNATURE_FIELD_NUMBER;
hash = (53 * hash) + getSignature().hashCode();
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
@java.lang.Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(wallet.core.jni.proto.Theta.SigningOutput prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
@java.lang.Override
public Builder toBuilder() {
return this == DEFAULT_INSTANCE
? new Builder() : new Builder().mergeFrom(this);
}
@java.lang.Override
protected Builder newBuilderForType(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* <pre>
*/ Transaction signing output
* </pre>
*
* Protobuf type {@code TW.Theta.Proto.SigningOutput}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:TW.Theta.Proto.SigningOutput)
wallet.core.jni.proto.Theta.SigningOutputOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningOutput_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningOutput_fieldAccessorTable
.ensureFieldAccessorsInitialized(
wallet.core.jni.proto.Theta.SigningOutput.class, wallet.core.jni.proto.Theta.SigningOutput.Builder.class);
}
// Construct using wallet.core.jni.proto.Theta.SigningOutput.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3
.alwaysUseFieldBuilders) {
}
}
@java.lang.Override
public Builder clear() {
super.clear();
encoded_ = com.google.protobuf.ByteString.EMPTY;
signature_ = com.google.protobuf.ByteString.EMPTY;
return this;
}
@java.lang.Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningOutput_descriptor;
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningOutput getDefaultInstanceForType() {
return wallet.core.jni.proto.Theta.SigningOutput.getDefaultInstance();
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningOutput build() {
wallet.core.jni.proto.Theta.SigningOutput result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningOutput buildPartial() {
wallet.core.jni.proto.Theta.SigningOutput result = new wallet.core.jni.proto.Theta.SigningOutput(this);
result.encoded_ = encoded_;
result.signature_ = signature_;
onBuilt();
return result;
}
@java.lang.Override
public Builder clone() {
return super.clone();
}
@java.lang.Override
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
java.lang.Object value) {
return super.setField(field, value);
}
@java.lang.Override
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return super.clearField(field);
}
@java.lang.Override
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@java.lang.Override
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, java.lang.Object value) {
return super.setRepeatedField(field, index, value);
}
@java.lang.Override
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
java.lang.Object value) {
return super.addRepeatedField(field, value);
}
@java.lang.Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof wallet.core.jni.proto.Theta.SigningOutput) {
return mergeFrom((wallet.core.jni.proto.Theta.SigningOutput)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(wallet.core.jni.proto.Theta.SigningOutput other) {
if (other == wallet.core.jni.proto.Theta.SigningOutput.getDefaultInstance()) return this;
if (other.getEncoded() != com.google.protobuf.ByteString.EMPTY) {
setEncoded(other.getEncoded());
}
if (other.getSignature() != com.google.protobuf.ByteString.EMPTY) {
setSignature(other.getSignature());
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
}
@java.lang.Override
public final boolean isInitialized() {
return true;
}
@java.lang.Override
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
wallet.core.jni.proto.Theta.SigningOutput parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (wallet.core.jni.proto.Theta.SigningOutput) e.getUnfinishedMessage();
throw e.unwrapIOException();
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private com.google.protobuf.ByteString encoded_ = com.google.protobuf.ByteString.EMPTY;
/**
* <pre>
*/ Signed and encoded transaction bytes
* </pre>
*
* <code>bytes encoded = 1;</code>
*/
public com.google.protobuf.ByteString getEncoded() {
return encoded_;
}
/**
* <pre>
*/ Signed and encoded transaction bytes
* </pre>
*
* <code>bytes encoded = 1;</code>
*/
public Builder setEncoded(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
encoded_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Signed and encoded transaction bytes
* </pre>
*
* <code>bytes encoded = 1;</code>
*/
public Builder clearEncoded() {
encoded_ = getDefaultInstance().getEncoded();
onChanged();
return this;
}
private com.google.protobuf.ByteString signature_ = com.google.protobuf.ByteString.EMPTY;
/**
* <pre>
*/ Signature
* </pre>
*
* <code>bytes signature = 2;</code>
*/
public com.google.protobuf.ByteString getSignature() {
return signature_;
}
/**
* <pre>
*/ Signature
* </pre>
*
* <code>bytes signature = 2;</code>
*/
public Builder setSignature(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
signature_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Signature
* </pre>
*
* <code>bytes signature = 2;</code>
*/
public Builder clearSignature() {
signature_ = getDefaultInstance().getSignature();
onChanged();
return this;
}
@java.lang.Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
@java.lang.Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:TW.Theta.Proto.SigningOutput)
}
// @@protoc_insertion_point(class_scope:TW.Theta.Proto.SigningOutput)
private static final wallet.core.jni.proto.Theta.SigningOutput DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new wallet.core.jni.proto.Theta.SigningOutput();
}
public static wallet.core.jni.proto.Theta.SigningOutput getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<SigningOutput>
PARSER = new com.google.protobuf.AbstractParser<SigningOutput>() {
@java.lang.Override
public SigningOutput parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new SigningOutput(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<SigningOutput> parser() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<SigningOutput> getParserForType() {
return PARSER;
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningOutput getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
private static final com.google.protobuf.Descriptors.Descriptor
internal_static_TW_Theta_Proto_SigningInput_descriptor;
private static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_TW_Theta_Proto_SigningInput_fieldAccessorTable;
private static final com.google.protobuf.Descriptors.Descriptor
internal_static_TW_Theta_Proto_SigningOutput_descriptor;
private static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_TW_Theta_Proto_SigningOutput_fieldAccessorTable;
public static com.google.protobuf.Descriptors.FileDescriptor
getDescriptor() {
return descriptor;
}
private static com.google.protobuf.Descriptors.FileDescriptor
descriptor;
static {
java.lang.String[] descriptorData = {
"\n\013Theta.proto\022\016TW.Theta.Proto\"\224\001\n\014Signin" +
"gInput\022\020\n\010chain_id\030\001 \001(\t\022\022\n\nto_address\030\002" +
" \001(\t\022\024\n\014theta_amount\030\003 \001(\014\022\024\n\014tfuel_amou" +
"nt\030\004 \001(\014\022\020\n\010sequence\030\005 \001(\004\022\013\n\003fee\030\006 \001(\014\022" +
"\023\n\013private_key\030\007 \001(\014\"3\n\rSigningOutput\022\017\n" +
"\007encoded\030\001 \001(\014\022\021\n\tsignature\030\002 \001(\014B\027\n\025wal" +
"let.core.jni.protob\006proto3"
};
com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() {
public com.google.protobuf.ExtensionRegistry assignDescriptors(
com.google.protobuf.Descriptors.FileDescriptor root) {
descriptor = root;
return null;
}
};
com.google.protobuf.Descriptors.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.Descriptors.FileDescriptor[] {
}, assigner);
internal_static_TW_Theta_Proto_SigningInput_descriptor =
getDescriptor().getMessageTypes().get(0);
internal_static_TW_Theta_Proto_SigningInput_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_TW_Theta_Proto_SigningInput_descriptor,
new java.lang.String[] { "ChainId", "ToAddress", "ThetaAmount", "TfuelAmount", "Sequence", "Fee", "PrivateKey", });
internal_static_TW_Theta_Proto_SigningOutput_descriptor =
getDescriptor().getMessageTypes().get(1);
internal_static_TW_Theta_Proto_SigningOutput_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_TW_Theta_Proto_SigningOutput_descriptor,
new java.lang.String[] { "Encoded", "Signature", });
}
// @@protoc_insertion_point(outer_class_scope)
}
| // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: Theta.proto
package wallet.core.jni.proto;
public final class Theta {
private Theta() {}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistryLite registry) {
}
public static void registerAllExtensions(
com.google.protobuf.ExtensionRegistry registry) {
registerAllExtensions(
(com.google.protobuf.ExtensionRegistryLite) registry);
}
public interface SigningInputOrBuilder extends
// @@protoc_insertion_point(interface_extends:TW.Theta.Proto.SigningInput)
com.google.protobuf.MessageOrBuilder {
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
java.lang.String getChainId();
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
com.google.protobuf.ByteString
FUNC_0();
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
java.lang.String getToAddress();
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
com.google.protobuf.ByteString
getToAddressBytes();
/**
* <pre>
*/ Theta token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes theta_amount = 3;</code>
*/
com.google.protobuf.ByteString getThetaAmount();
/**
* <pre>
*/ TFuel token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes tfuel_amount = 4;</code>
*/
com.google.protobuf.ByteString getTfuelAmount();
/**
* <pre>
*/ Sequence number of the transaction for the sender address
* </pre>
*
* <code>uint64 sequence = 5;</code>
*/
long getSequence();
/**
* <pre>
*/ Fee amount in TFuel wei for the transaction (256-bit number)
* </pre>
*
* <code>bytes fee = 6;</code>
*/
com.google.protobuf.ByteString getFee();
/**
* <pre>
*/ Private key
* </pre>
*
* <code>bytes private_key = 7;</code>
*/
com.google.protobuf.ByteString getPrivateKey();
}
/**
* <pre>
*/ Input data necessary to create a signed transaction
* </pre>
*
* Protobuf type {@code TW.Theta.Proto.SigningInput}
*/
public static final class SigningInput extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:TW.Theta.Proto.SigningInput)
SigningInputOrBuilder {
private static final long serialVersionUID = 0L;
// Use SigningInput.newBuilder() to construct.
private SigningInput(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private SigningInput() {
chainId_ = "";
toAddress_ = "";
thetaAmount_ = com.google.protobuf.ByteString.EMPTY;
tfuelAmount_ = com.google.protobuf.ByteString.EMPTY;
fee_ = com.google.protobuf.ByteString.EMPTY;
privateKey_ = com.google.protobuf.ByteString.EMPTY;
}
@java.lang.Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
private SigningInput(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
if (extensionRegistry == null) {
throw new java.lang.NullPointerException();
}
int VAR_0 = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
case 10: {
java.lang.String s = input.readStringRequireUtf8();
chainId_ = s;
break;
}
case 18: {
java.lang.String s = input.readStringRequireUtf8();
toAddress_ = s;
break;
}
case 26: {
thetaAmount_ = input.FUNC_1();
break;
}
case 34: {
tfuelAmount_ = input.FUNC_1();
break;
}
case 40: {
sequence_ = input.readUInt64();
break;
}
case 50: {
fee_ = input.FUNC_1();
break;
}
case 58: {
privateKey_ = input.FUNC_1();
break;
}
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
done = true;
}
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.CLASS_0.Descriptor
getDescriptor() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningInput_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningInput_fieldAccessorTable
.ensureFieldAccessorsInitialized(
wallet.core.jni.proto.Theta.SigningInput.class, wallet.core.jni.proto.Theta.SigningInput.Builder.class);
}
public static final int CHAIN_ID_FIELD_NUMBER = 1;
private volatile java.lang.Object chainId_;
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
public java.lang.String getChainId() {
java.lang.Object ref = chainId_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
chainId_ = s;
return s;
}
}
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
public com.google.protobuf.ByteString
FUNC_0() {
java.lang.Object ref = chainId_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.FUNC_2(
(java.lang.String) ref);
chainId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int TO_ADDRESS_FIELD_NUMBER = 2;
private volatile java.lang.Object toAddress_;
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
public java.lang.String getToAddress() {
java.lang.Object ref = toAddress_;
if (ref instanceof java.lang.String) {
return (java.lang.String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
toAddress_ = s;
return s;
}
}
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
public com.google.protobuf.ByteString
getToAddressBytes() {
java.lang.Object ref = toAddress_;
if (ref instanceof java.lang.String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.FUNC_2(
(java.lang.String) ref);
toAddress_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int THETA_AMOUNT_FIELD_NUMBER = 3;
private com.google.protobuf.ByteString thetaAmount_;
/**
* <pre>
*/ Theta token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes theta_amount = 3;</code>
*/
public com.google.protobuf.ByteString getThetaAmount() {
return thetaAmount_;
}
public static final int TFUEL_AMOUNT_FIELD_NUMBER = 4;
private com.google.protobuf.ByteString tfuelAmount_;
/**
* <pre>
*/ TFuel token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes tfuel_amount = 4;</code>
*/
public com.google.protobuf.ByteString getTfuelAmount() {
return tfuelAmount_;
}
public static final int SEQUENCE_FIELD_NUMBER = 5;
private long sequence_;
/**
* <pre>
*/ Sequence number of the transaction for the sender address
* </pre>
*
* <code>uint64 sequence = 5;</code>
*/
public long getSequence() {
return sequence_;
}
public static final int FEE_FIELD_NUMBER = 6;
private com.google.protobuf.ByteString fee_;
/**
* <pre>
*/ Fee amount in TFuel wei for the transaction (256-bit number)
* </pre>
*
* <code>bytes fee = 6;</code>
*/
public com.google.protobuf.ByteString getFee() {
return fee_;
}
public static final int PRIVATE_KEY_FIELD_NUMBER = 7;
private com.google.protobuf.ByteString privateKey_;
/**
* <pre>
*/ Private key
* </pre>
*
* <code>bytes private_key = 7;</code>
*/
public com.google.protobuf.ByteString getPrivateKey() {
return privateKey_;
}
private byte memoizedIsInitialized = -1;
@java.lang.Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
@java.lang.Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (!FUNC_0().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 1, chainId_);
}
if (!getToAddressBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, toAddress_);
}
if (!thetaAmount_.isEmpty()) {
output.writeBytes(3, thetaAmount_);
}
if (!tfuelAmount_.isEmpty()) {
output.writeBytes(4, tfuelAmount_);
}
if (sequence_ != 0L) {
output.writeUInt64(5, sequence_);
}
if (!fee_.isEmpty()) {
output.writeBytes(6, fee_);
}
if (!privateKey_.isEmpty()) {
output.writeBytes(7, privateKey_);
}
unknownFields.writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!FUNC_0().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, chainId_);
}
if (!getToAddressBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, toAddress_);
}
if (!thetaAmount_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(3, thetaAmount_);
}
if (!tfuelAmount_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(4, tfuelAmount_);
}
if (sequence_ != 0L) {
size += com.google.protobuf.CodedOutputStream
.computeUInt64Size(5, sequence_);
}
if (!fee_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(6, fee_);
}
if (!privateKey_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(7, privateKey_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
}
@java.lang.Override
public boolean equals(final java.lang.Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof wallet.core.jni.proto.Theta.SigningInput)) {
return super.equals(obj);
}
wallet.core.jni.proto.Theta.SigningInput other = (wallet.core.jni.proto.Theta.SigningInput) obj;
if (!getChainId()
.equals(other.getChainId())) return false;
if (!getToAddress()
.equals(other.getToAddress())) return false;
if (!getThetaAmount()
.equals(other.getThetaAmount())) return false;
if (!getTfuelAmount()
.equals(other.getTfuelAmount())) return false;
if (getSequence()
!= other.getSequence()) return false;
if (!getFee()
.equals(other.getFee())) return false;
if (!getPrivateKey()
.equals(other.getPrivateKey())) return false;
if (!unknownFields.equals(other.unknownFields)) return false;
return true;
}
@java.lang.Override
public int FUNC_3() {
if (VAR_2 != 0) {
return VAR_2;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().FUNC_3();
hash = (37 * hash) + CHAIN_ID_FIELD_NUMBER;
hash = (53 * hash) + getChainId().FUNC_3();
hash = (37 * hash) + TO_ADDRESS_FIELD_NUMBER;
hash = (53 * hash) + getToAddress().FUNC_3();
hash = (37 * hash) + THETA_AMOUNT_FIELD_NUMBER;
hash = (53 * hash) + getThetaAmount().FUNC_3();
hash = (37 * hash) + TFUEL_AMOUNT_FIELD_NUMBER;
hash = (53 * hash) + getTfuelAmount().FUNC_3();
hash = (37 * hash) + SEQUENCE_FIELD_NUMBER;
hash = (53 * hash) + com.google.protobuf.Internal.hashLong(
getSequence());
hash = (37 * hash) + FEE_FIELD_NUMBER;
hash = (53 * hash) + getFee().FUNC_3();
hash = (37 * hash) + PRIVATE_KEY_FIELD_NUMBER;
hash = (53 * hash) + getPrivateKey().FUNC_3();
hash = (29 * hash) + unknownFields.FUNC_3();
VAR_2 = hash;
return hash;
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningInput parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static wallet.core.jni.proto.Theta.SigningInput parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static wallet.core.jni.proto.Theta.SigningInput parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
@java.lang.Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return VAR_3.FUNC_4();
}
public static Builder newBuilder(wallet.core.jni.proto.Theta.SigningInput prototype) {
return VAR_3.FUNC_4().mergeFrom(prototype);
}
@java.lang.Override
public Builder FUNC_4() {
return this == VAR_3
? new Builder() : new Builder().mergeFrom(this);
}
@java.lang.Override
protected Builder newBuilderForType(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* <pre>
*/ Input data necessary to create a signed transaction
* </pre>
*
* Protobuf type {@code TW.Theta.Proto.SigningInput}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:TW.Theta.Proto.SigningInput)
wallet.core.jni.proto.Theta.SigningInputOrBuilder {
public static final com.google.protobuf.CLASS_0.Descriptor
getDescriptor() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningInput_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningInput_fieldAccessorTable
.ensureFieldAccessorsInitialized(
wallet.core.jni.proto.Theta.SigningInput.class, wallet.core.jni.proto.Theta.SigningInput.Builder.class);
}
// Construct using wallet.core.jni.proto.Theta.SigningInput.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3
.alwaysUseFieldBuilders) {
}
}
@java.lang.Override
public Builder clear() {
super.clear();
chainId_ = "";
toAddress_ = "";
thetaAmount_ = com.google.protobuf.ByteString.EMPTY;
tfuelAmount_ = com.google.protobuf.ByteString.EMPTY;
sequence_ = 0L;
fee_ = com.google.protobuf.ByteString.EMPTY;
privateKey_ = com.google.protobuf.ByteString.EMPTY;
return this;
}
@java.lang.Override
public com.google.protobuf.CLASS_0.Descriptor
getDescriptorForType() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningInput_descriptor;
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningInput getDefaultInstanceForType() {
return wallet.core.jni.proto.Theta.SigningInput.getDefaultInstance();
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningInput build() {
wallet.core.jni.proto.Theta.SigningInput result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningInput buildPartial() {
wallet.core.jni.proto.Theta.SigningInput result = new wallet.core.jni.proto.Theta.SigningInput(this);
result.chainId_ = chainId_;
result.toAddress_ = toAddress_;
result.thetaAmount_ = thetaAmount_;
result.tfuelAmount_ = tfuelAmount_;
result.sequence_ = sequence_;
result.fee_ = fee_;
result.privateKey_ = privateKey_;
FUNC_5();
return result;
}
@java.lang.Override
public Builder clone() {
return super.clone();
}
@java.lang.Override
public Builder setField(
com.google.protobuf.CLASS_0.FieldDescriptor field,
java.lang.Object value) {
return super.setField(field, value);
}
@java.lang.Override
public Builder clearField(
com.google.protobuf.CLASS_0.FieldDescriptor field) {
return super.clearField(field);
}
@java.lang.Override
public Builder clearOneof(
com.google.protobuf.CLASS_0.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@java.lang.Override
public Builder setRepeatedField(
com.google.protobuf.CLASS_0.FieldDescriptor field,
int index, java.lang.Object value) {
return super.setRepeatedField(field, index, value);
}
@java.lang.Override
public Builder addRepeatedField(
com.google.protobuf.CLASS_0.FieldDescriptor field,
java.lang.Object value) {
return super.addRepeatedField(field, value);
}
@java.lang.Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof wallet.core.jni.proto.Theta.SigningInput) {
return mergeFrom((wallet.core.jni.proto.Theta.SigningInput)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(wallet.core.jni.proto.Theta.SigningInput other) {
if (other == wallet.core.jni.proto.Theta.SigningInput.getDefaultInstance()) return this;
if (!other.getChainId().isEmpty()) {
chainId_ = other.chainId_;
onChanged();
}
if (!other.getToAddress().isEmpty()) {
toAddress_ = other.toAddress_;
onChanged();
}
if (other.getThetaAmount() != com.google.protobuf.ByteString.EMPTY) {
setThetaAmount(other.getThetaAmount());
}
if (other.getTfuelAmount() != com.google.protobuf.ByteString.EMPTY) {
setTfuelAmount(other.getTfuelAmount());
}
if (other.getSequence() != 0L) {
setSequence(other.getSequence());
}
if (other.getFee() != com.google.protobuf.ByteString.EMPTY) {
setFee(other.getFee());
}
if (other.getPrivateKey() != com.google.protobuf.ByteString.EMPTY) {
setPrivateKey(other.getPrivateKey());
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
}
@java.lang.Override
public final boolean isInitialized() {
return true;
}
@java.lang.Override
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
wallet.core.jni.proto.Theta.SigningInput VAR_4 = null;
try {
VAR_4 = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
VAR_4 = (wallet.core.jni.proto.Theta.SigningInput) e.getUnfinishedMessage();
throw e.unwrapIOException();
} finally {
if (VAR_4 != null) {
mergeFrom(VAR_4);
}
}
return this;
}
private java.lang.Object chainId_ = "";
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
public java.lang.String getChainId() {
java.lang.Object ref = chainId_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
chainId_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
public com.google.protobuf.ByteString
FUNC_0() {
java.lang.Object ref = chainId_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.FUNC_2(
(java.lang.String) ref);
chainId_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
public Builder setChainId(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
chainId_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
public Builder clearChainId() {
chainId_ = getDefaultInstance().getChainId();
onChanged();
return this;
}
/**
* <pre>
*/ Chain ID string, mainnet, testnet and privatenet
* </pre>
*
* <code>string chain_id = 1;</code>
*/
public Builder setChainIdBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
chainId_ = value;
onChanged();
return this;
}
private java.lang.Object toAddress_ = "";
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
public java.lang.String getToAddress() {
java.lang.Object ref = toAddress_;
if (!(ref instanceof java.lang.String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
java.lang.String s = bs.toStringUtf8();
toAddress_ = s;
return s;
} else {
return (java.lang.String) ref;
}
}
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
public com.google.protobuf.ByteString
getToAddressBytes() {
java.lang.Object ref = toAddress_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.FUNC_2(
(java.lang.String) ref);
toAddress_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
public Builder setToAddress(
java.lang.String value) {
if (value == null) {
throw new NullPointerException();
}
toAddress_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
public Builder clearToAddress() {
toAddress_ = getDefaultInstance().getToAddress();
onChanged();
return this;
}
/**
* <pre>
*/ Recipient address
* </pre>
*
* <code>string to_address = 2;</code>
*/
public Builder setToAddressBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
toAddress_ = value;
onChanged();
return this;
}
private com.google.protobuf.ByteString thetaAmount_ = com.google.protobuf.ByteString.EMPTY;
/**
* <pre>
*/ Theta token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes theta_amount = 3;</code>
*/
public com.google.protobuf.ByteString getThetaAmount() {
return thetaAmount_;
}
/**
* <pre>
*/ Theta token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes theta_amount = 3;</code>
*/
public Builder setThetaAmount(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
thetaAmount_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Theta token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes theta_amount = 3;</code>
*/
public Builder FUNC_6() {
thetaAmount_ = getDefaultInstance().getThetaAmount();
onChanged();
return this;
}
private com.google.protobuf.ByteString tfuelAmount_ = com.google.protobuf.ByteString.EMPTY;
/**
* <pre>
*/ TFuel token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes tfuel_amount = 4;</code>
*/
public com.google.protobuf.ByteString getTfuelAmount() {
return tfuelAmount_;
}
/**
* <pre>
*/ TFuel token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes tfuel_amount = 4;</code>
*/
public Builder setTfuelAmount(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
tfuelAmount_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ TFuel token amount to send in wei (256-bit number)
* </pre>
*
* <code>bytes tfuel_amount = 4;</code>
*/
public Builder FUNC_7() {
tfuelAmount_ = getDefaultInstance().getTfuelAmount();
onChanged();
return this;
}
private long sequence_ ;
/**
* <pre>
*/ Sequence number of the transaction for the sender address
* </pre>
*
* <code>uint64 sequence = 5;</code>
*/
public long getSequence() {
return sequence_;
}
/**
* <pre>
*/ Sequence number of the transaction for the sender address
* </pre>
*
* <code>uint64 sequence = 5;</code>
*/
public Builder setSequence(long value) {
sequence_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Sequence number of the transaction for the sender address
* </pre>
*
* <code>uint64 sequence = 5;</code>
*/
public Builder clearSequence() {
sequence_ = 0L;
onChanged();
return this;
}
private com.google.protobuf.ByteString fee_ = com.google.protobuf.ByteString.EMPTY;
/**
* <pre>
*/ Fee amount in TFuel wei for the transaction (256-bit number)
* </pre>
*
* <code>bytes fee = 6;</code>
*/
public com.google.protobuf.ByteString getFee() {
return fee_;
}
/**
* <pre>
*/ Fee amount in TFuel wei for the transaction (256-bit number)
* </pre>
*
* <code>bytes fee = 6;</code>
*/
public Builder setFee(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
fee_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Fee amount in TFuel wei for the transaction (256-bit number)
* </pre>
*
* <code>bytes fee = 6;</code>
*/
public Builder clearFee() {
fee_ = getDefaultInstance().getFee();
onChanged();
return this;
}
private com.google.protobuf.ByteString privateKey_ = com.google.protobuf.ByteString.EMPTY;
/**
* <pre>
*/ Private key
* </pre>
*
* <code>bytes private_key = 7;</code>
*/
public com.google.protobuf.ByteString getPrivateKey() {
return privateKey_;
}
/**
* <pre>
*/ Private key
* </pre>
*
* <code>bytes private_key = 7;</code>
*/
public Builder setPrivateKey(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
privateKey_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Private key
* </pre>
*
* <code>bytes private_key = 7;</code>
*/
public Builder clearPrivateKey() {
privateKey_ = getDefaultInstance().getPrivateKey();
onChanged();
return this;
}
@java.lang.Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
@java.lang.Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:TW.Theta.Proto.SigningInput)
}
// @@protoc_insertion_point(class_scope:TW.Theta.Proto.SigningInput)
private static final wallet.core.jni.proto.Theta.SigningInput VAR_3;
static {
VAR_3 = new wallet.core.jni.proto.Theta.SigningInput();
}
public static wallet.core.jni.proto.Theta.SigningInput getDefaultInstance() {
return VAR_3;
}
private static final com.google.protobuf.Parser<SigningInput>
PARSER = new com.google.protobuf.AbstractParser<SigningInput>() {
@java.lang.Override
public SigningInput parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new SigningInput(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<SigningInput> FUNC_8() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<SigningInput> getParserForType() {
return PARSER;
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningInput getDefaultInstanceForType() {
return VAR_3;
}
}
public interface CLASS_1 extends
// @@protoc_insertion_point(interface_extends:TW.Theta.Proto.SigningOutput)
com.google.protobuf.MessageOrBuilder {
/**
* <pre>
*/ Signed and encoded transaction bytes
* </pre>
*
* <code>bytes encoded = 1;</code>
*/
com.google.protobuf.ByteString getEncoded();
/**
* <pre>
*/ Signature
* </pre>
*
* <code>bytes signature = 2;</code>
*/
com.google.protobuf.ByteString getSignature();
}
/**
* <pre>
*/ Transaction signing output
* </pre>
*
* Protobuf type {@code TW.Theta.Proto.SigningOutput}
*/
public static final class SigningOutput extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:TW.Theta.Proto.SigningOutput)
CLASS_1 {
private static final long serialVersionUID = 0L;
// Use SigningOutput.newBuilder() to construct.
private SigningOutput(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private SigningOutput() {
encoded_ = com.google.protobuf.ByteString.EMPTY;
signature_ = com.google.protobuf.ByteString.EMPTY;
}
@java.lang.Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
private SigningOutput(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
if (extensionRegistry == null) {
throw new java.lang.NullPointerException();
}
int VAR_0 = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
case 10: {
encoded_ = input.FUNC_1();
break;
}
case 18: {
signature_ = input.FUNC_1();
break;
}
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
done = true;
}
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e).setUnfinishedMessage(this);
} finally {
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.CLASS_0.Descriptor
getDescriptor() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningOutput_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningOutput_fieldAccessorTable
.ensureFieldAccessorsInitialized(
wallet.core.jni.proto.Theta.SigningOutput.class, wallet.core.jni.proto.Theta.SigningOutput.Builder.class);
}
public static final int ENCODED_FIELD_NUMBER = 1;
private com.google.protobuf.ByteString encoded_;
/**
* <pre>
*/ Signed and encoded transaction bytes
* </pre>
*
* <code>bytes encoded = 1;</code>
*/
public com.google.protobuf.ByteString getEncoded() {
return encoded_;
}
public static final int VAR_5 = 2;
private com.google.protobuf.ByteString signature_;
/**
* <pre>
*/ Signature
* </pre>
*
* <code>bytes signature = 2;</code>
*/
public com.google.protobuf.ByteString getSignature() {
return signature_;
}
private byte memoizedIsInitialized = -1;
@java.lang.Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
@java.lang.Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (!encoded_.isEmpty()) {
output.writeBytes(1, encoded_);
}
if (!signature_.isEmpty()) {
output.writeBytes(2, signature_);
}
unknownFields.writeTo(output);
}
@java.lang.Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!encoded_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(1, encoded_);
}
if (!signature_.isEmpty()) {
size += com.google.protobuf.CodedOutputStream
.computeBytesSize(2, signature_);
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
}
@java.lang.Override
public boolean equals(final java.lang.Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof wallet.core.jni.proto.Theta.SigningOutput)) {
return super.equals(obj);
}
wallet.core.jni.proto.Theta.SigningOutput other = (wallet.core.jni.proto.Theta.SigningOutput) obj;
if (!getEncoded()
.equals(other.getEncoded())) return false;
if (!getSignature()
.equals(other.getSignature())) return false;
if (!unknownFields.equals(other.unknownFields)) return false;
return true;
}
@java.lang.Override
public int FUNC_3() {
if (VAR_2 != 0) {
return VAR_2;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().FUNC_3();
hash = (37 * hash) + ENCODED_FIELD_NUMBER;
hash = (53 * hash) + getEncoded().FUNC_3();
hash = (37 * hash) + VAR_5;
hash = (53 * hash) + getSignature().FUNC_3();
hash = (29 * hash) + unknownFields.FUNC_3();
VAR_2 = hash;
return hash;
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static wallet.core.jni.proto.Theta.SigningOutput parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
@java.lang.Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return VAR_3.FUNC_4();
}
public static Builder newBuilder(wallet.core.jni.proto.Theta.SigningOutput prototype) {
return VAR_3.FUNC_4().mergeFrom(prototype);
}
@java.lang.Override
public Builder FUNC_4() {
return this == VAR_3
? new Builder() : new Builder().mergeFrom(this);
}
@java.lang.Override
protected Builder newBuilderForType(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* <pre>
*/ Transaction signing output
* </pre>
*
* Protobuf type {@code TW.Theta.Proto.SigningOutput}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:TW.Theta.Proto.SigningOutput)
wallet.core.jni.proto.Theta.CLASS_1 {
public static final com.google.protobuf.CLASS_0.Descriptor
getDescriptor() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningOutput_descriptor;
}
@java.lang.Override
protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internalGetFieldAccessorTable() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningOutput_fieldAccessorTable
.ensureFieldAccessorsInitialized(
wallet.core.jni.proto.Theta.SigningOutput.class, wallet.core.jni.proto.Theta.SigningOutput.Builder.class);
}
// Construct using wallet.core.jni.proto.Theta.SigningOutput.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3
.alwaysUseFieldBuilders) {
}
}
@java.lang.Override
public Builder clear() {
super.clear();
encoded_ = com.google.protobuf.ByteString.EMPTY;
signature_ = com.google.protobuf.ByteString.EMPTY;
return this;
}
@java.lang.Override
public com.google.protobuf.CLASS_0.Descriptor
getDescriptorForType() {
return wallet.core.jni.proto.Theta.internal_static_TW_Theta_Proto_SigningOutput_descriptor;
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningOutput getDefaultInstanceForType() {
return wallet.core.jni.proto.Theta.SigningOutput.getDefaultInstance();
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningOutput build() {
wallet.core.jni.proto.Theta.SigningOutput result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningOutput buildPartial() {
wallet.core.jni.proto.Theta.SigningOutput result = new wallet.core.jni.proto.Theta.SigningOutput(this);
result.encoded_ = encoded_;
result.signature_ = signature_;
FUNC_5();
return result;
}
@java.lang.Override
public Builder clone() {
return super.clone();
}
@java.lang.Override
public Builder setField(
com.google.protobuf.CLASS_0.FieldDescriptor field,
java.lang.Object value) {
return super.setField(field, value);
}
@java.lang.Override
public Builder clearField(
com.google.protobuf.CLASS_0.FieldDescriptor field) {
return super.clearField(field);
}
@java.lang.Override
public Builder clearOneof(
com.google.protobuf.CLASS_0.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@java.lang.Override
public Builder setRepeatedField(
com.google.protobuf.CLASS_0.FieldDescriptor field,
int index, java.lang.Object value) {
return super.setRepeatedField(field, index, value);
}
@java.lang.Override
public Builder addRepeatedField(
com.google.protobuf.CLASS_0.FieldDescriptor field,
java.lang.Object value) {
return super.addRepeatedField(field, value);
}
@java.lang.Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof wallet.core.jni.proto.Theta.SigningOutput) {
return mergeFrom((wallet.core.jni.proto.Theta.SigningOutput)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(wallet.core.jni.proto.Theta.SigningOutput other) {
if (other == wallet.core.jni.proto.Theta.SigningOutput.getDefaultInstance()) return this;
if (other.getEncoded() != com.google.protobuf.ByteString.EMPTY) {
setEncoded(other.getEncoded());
}
if (other.getSignature() != com.google.protobuf.ByteString.EMPTY) {
setSignature(other.getSignature());
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
}
@java.lang.Override
public final boolean isInitialized() {
return true;
}
@java.lang.Override
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
wallet.core.jni.proto.Theta.SigningOutput VAR_4 = null;
try {
VAR_4 = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
VAR_4 = (wallet.core.jni.proto.Theta.SigningOutput) e.getUnfinishedMessage();
throw e.unwrapIOException();
} finally {
if (VAR_4 != null) {
mergeFrom(VAR_4);
}
}
return this;
}
private com.google.protobuf.ByteString encoded_ = com.google.protobuf.ByteString.EMPTY;
/**
* <pre>
*/ Signed and encoded transaction bytes
* </pre>
*
* <code>bytes encoded = 1;</code>
*/
public com.google.protobuf.ByteString getEncoded() {
return encoded_;
}
/**
* <pre>
*/ Signed and encoded transaction bytes
* </pre>
*
* <code>bytes encoded = 1;</code>
*/
public Builder setEncoded(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
encoded_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Signed and encoded transaction bytes
* </pre>
*
* <code>bytes encoded = 1;</code>
*/
public Builder clearEncoded() {
encoded_ = getDefaultInstance().getEncoded();
onChanged();
return this;
}
private com.google.protobuf.ByteString signature_ = com.google.protobuf.ByteString.EMPTY;
/**
* <pre>
*/ Signature
* </pre>
*
* <code>bytes signature = 2;</code>
*/
public com.google.protobuf.ByteString getSignature() {
return signature_;
}
/**
* <pre>
*/ Signature
* </pre>
*
* <code>bytes signature = 2;</code>
*/
public Builder setSignature(com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
signature_ = value;
onChanged();
return this;
}
/**
* <pre>
*/ Signature
* </pre>
*
* <code>bytes signature = 2;</code>
*/
public Builder clearSignature() {
signature_ = getDefaultInstance().getSignature();
onChanged();
return this;
}
@java.lang.Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
@java.lang.Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:TW.Theta.Proto.SigningOutput)
}
// @@protoc_insertion_point(class_scope:TW.Theta.Proto.SigningOutput)
private static final wallet.core.jni.proto.Theta.SigningOutput VAR_3;
static {
VAR_3 = new wallet.core.jni.proto.Theta.SigningOutput();
}
public static wallet.core.jni.proto.Theta.SigningOutput getDefaultInstance() {
return VAR_3;
}
private static final com.google.protobuf.Parser<SigningOutput>
PARSER = new com.google.protobuf.AbstractParser<SigningOutput>() {
@java.lang.Override
public SigningOutput parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new SigningOutput(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<SigningOutput> FUNC_8() {
return PARSER;
}
@java.lang.Override
public com.google.protobuf.Parser<SigningOutput> getParserForType() {
return PARSER;
}
@java.lang.Override
public wallet.core.jni.proto.Theta.SigningOutput getDefaultInstanceForType() {
return VAR_3;
}
}
private static final com.google.protobuf.CLASS_0.Descriptor
internal_static_TW_Theta_Proto_SigningInput_descriptor;
private static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_TW_Theta_Proto_SigningInput_fieldAccessorTable;
private static final com.google.protobuf.CLASS_0.Descriptor
internal_static_TW_Theta_Proto_SigningOutput_descriptor;
private static final
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
internal_static_TW_Theta_Proto_SigningOutput_fieldAccessorTable;
public static com.google.protobuf.CLASS_0.FileDescriptor
getDescriptor() {
return descriptor;
}
private static com.google.protobuf.CLASS_0.FileDescriptor
descriptor;
static {
java.lang.String[] descriptorData = {
"\n\013Theta.proto\022\016TW.Theta.Proto\"\224\001\n\014Signin" +
"gInput\022\020\n\010chain_id\030\001 \001(\t\022\022\n\nto_address\030\002" +
" \001(\t\022\024\n\014theta_amount\030\003 \001(\014\022\024\n\014tfuel_amou" +
"nt\030\004 \001(\014\022\020\n\010sequence\030\005 \001(\004\022\013\n\003fee\030\006 \001(\014\022" +
"\023\n\013private_key\030\007 \001(\014\"3\n\rSigningOutput\022\017\n" +
"\007encoded\030\001 \001(\014\022\021\n\tsignature\030\002 \001(\014B\027\n\025wal" +
"let.core.jni.protob\006proto3"
};
com.google.protobuf.CLASS_0.FileDescriptor.CLASS_2 assigner =
new com.google.protobuf.CLASS_0.FileDescriptor. CLASS_2() {
public com.google.protobuf.ExtensionRegistry assignDescriptors(
com.google.protobuf.CLASS_0.FileDescriptor root) {
descriptor = root;
return null;
}
};
com.google.protobuf.VAR_1.FileDescriptor
.internalBuildGeneratedFileFrom(descriptorData,
new com.google.protobuf.CLASS_0.FileDescriptor[] {
}, assigner);
internal_static_TW_Theta_Proto_SigningInput_descriptor =
getDescriptor().getMessageTypes().get(0);
internal_static_TW_Theta_Proto_SigningInput_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_TW_Theta_Proto_SigningInput_descriptor,
new java.lang.String[] { "ChainId", "ToAddress", "ThetaAmount", "TfuelAmount", "Sequence", "Fee", "PrivateKey", });
internal_static_TW_Theta_Proto_SigningOutput_descriptor =
getDescriptor().getMessageTypes().get(1);
internal_static_TW_Theta_Proto_SigningOutput_fieldAccessorTable = new
com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
internal_static_TW_Theta_Proto_SigningOutput_descriptor,
new java.lang.String[] { "Encoded", "Signature", });
}
// @@protoc_insertion_point(outer_class_scope)
}
| 0.066664 | {'FUNC_0': 'getChainIdBytes', 'VAR_0': 'mutable_bitField0_', 'FUNC_1': 'readBytes', 'CLASS_0': 'Descriptors', 'VAR_1': 'Descriptors', 'FUNC_2': 'copyFromUtf8', 'FUNC_3': 'hashCode', 'VAR_2': 'memoizedHashCode', 'VAR_3': 'DEFAULT_INSTANCE', 'FUNC_4': 'toBuilder', 'FUNC_5': 'onBuilt', 'VAR_4': 'parsedMessage', 'FUNC_6': 'clearThetaAmount', 'FUNC_7': 'clearTfuelAmount', 'FUNC_8': 'parser', 'CLASS_1': 'SigningOutputOrBuilder', 'VAR_5': 'SIGNATURE_FIELD_NUMBER', 'CLASS_2': 'InternalDescriptorAssigner'} | java | OOP | 0.81% |
/**
* Ozone Manager failures.
*/
public abstract static class OzoneFailures extends Failures {
@Override
public void validateFailure(MiniOzoneChaosCluster cluster) {
if (cluster.getOzoneManagersList().size() < 3) {
throw new IllegalArgumentException("Not enough number of " +
"OzoneManagers to test chaos on OzoneManagers. Set number of " +
"OzoneManagers to at least 3");
}
}
} | /**
* Ozone Manager failures.
*/
public abstract static class CLASS_0 extends Failures {
@VAR_0
public void validateFailure(MiniOzoneChaosCluster cluster) {
if (cluster.getOzoneManagersList().FUNC_0() < 3) {
throw new IllegalArgumentException("Not enough number of " +
"OzoneManagers to test chaos on OzoneManagers. Set number of " +
"OzoneManagers to at least 3");
}
}
} | 0.220648 | {'CLASS_0': 'OzoneFailures', 'VAR_0': 'Override', 'FUNC_0': 'size'} | java | OOP | 64.10% |
package org.firstinspires.ftc.teamcode.tests;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.hardware.DcMotor;
@Disabled
@Autonomous(name = "Individual Motor Test", group = "Driving Forward")
public class MotorTest extends OpMode{
DcMotor motor1, motor2;
@Override
public void init() {
motor1 = this.hardwareMap.dcMotor.get("0");
motor2 = this.hardwareMap.dcMotor.get("1");
}
@Override
public void loop() {
if(gamepad1.a){
motor1.setPower(1);
motor2.setPower(1);
}else{
motor1.setPower(gamepad1.left_stick_y);
motor2.setPower(gamepad1.right_stick_y);
}
}
} | package IMPORT_0.firstinspires.ftc.teamcode.tests;
import com.qualcomm.robotcore.eventloop.opmode.Autonomous;
import com.qualcomm.robotcore.eventloop.opmode.Disabled;
import com.qualcomm.robotcore.eventloop.opmode.OpMode;
import com.qualcomm.robotcore.hardware.DcMotor;
@Disabled
@Autonomous(name = "Individual Motor Test", group = "Driving Forward")
public class MotorTest extends OpMode{
DcMotor motor1, motor2;
@Override
public void init() {
motor1 = this.hardwareMap.dcMotor.get("0");
motor2 = this.hardwareMap.dcMotor.get("1");
}
@Override
public void loop() {
if(gamepad1.a){
motor1.setPower(1);
motor2.setPower(1);
}else{
motor1.setPower(gamepad1.left_stick_y);
motor2.setPower(gamepad1.right_stick_y);
}
}
} | 0.017181 | {'IMPORT_0': 'org'} | java | Hibrido | 100.00% |
/**
* Method adds order to order book.
* @param o order to add
* @return true if order added and false else.
*/
public boolean addOrder(Order o) {
if (o.getType() == OrderType.BUY) {
return addBid(o);
} else {
return addAsk(o);
}
} | /**
* Method adds order to order book.
* @param o order to add
* @return true if order added and false else.
*/
public boolean addOrder(CLASS_0 o) {
if (o.FUNC_0() == OrderType.BUY) {
return FUNC_1(o);
} else {
return addAsk(o);
}
} | 0.164748 | {'CLASS_0': 'Order', 'FUNC_0': 'getType', 'FUNC_1': 'addBid'} | java | Procedural | 61.54% |
package network.instances;
import java.io.Serializable;
import java.util.Deque;
import network.framework.format.Mail;
import network.framework.format.Request;
public class DataDecorator implements Mail {
/**
* Generated Serial ID
*/
private static final long serialVersionUID = -6320582607260270478L;
Request request;
Serializable data;
Deque<String> anscestralPath;
public DataDecorator (Request r, Serializable data, Deque<String> path) {
this.request = r;
this.data = data;
this.anscestralPath = path;
}
@Override
public Request getRequest() {
return request;
}
@Override
public Serializable getData() {
return data;
}
@Override
public Deque<String> getPath() {
return anscestralPath;
}
}
| package IMPORT_0.IMPORT_1;
import IMPORT_2.IMPORT_3.IMPORT_4;
import IMPORT_2.IMPORT_5.IMPORT_6;
import IMPORT_0.framework.IMPORT_7.IMPORT_8;
import IMPORT_0.framework.IMPORT_7.IMPORT_9;
public class CLASS_0 implements IMPORT_8 {
/**
* Generated Serial ID
*/
private static final long VAR_0 = -6320582607260270478L;
IMPORT_9 VAR_1;
IMPORT_4 VAR_2;
IMPORT_6<CLASS_1> VAR_3;
public CLASS_0 (IMPORT_9 VAR_4, IMPORT_4 VAR_2, IMPORT_6<CLASS_1> VAR_5) {
this.VAR_1 = VAR_4;
this.VAR_2 = VAR_2;
this.VAR_3 = VAR_5;
}
@VAR_6
public IMPORT_9 FUNC_0() {
return VAR_1;
}
@VAR_6
public IMPORT_4 FUNC_1() {
return VAR_2;
}
@VAR_6
public IMPORT_6<CLASS_1> getPath() {
return VAR_3;
}
}
| 0.803892 | {'IMPORT_0': 'network', 'IMPORT_1': 'instances', 'IMPORT_2': 'java', 'IMPORT_3': 'io', 'IMPORT_4': 'Serializable', 'IMPORT_5': 'util', 'IMPORT_6': 'Deque', 'IMPORT_7': 'format', 'IMPORT_8': 'Mail', 'IMPORT_9': 'Request', 'CLASS_0': 'DataDecorator', 'VAR_0': 'serialVersionUID', 'VAR_1': 'request', 'VAR_2': 'data', 'CLASS_1': 'String', 'VAR_3': 'anscestralPath', 'VAR_4': 'r', 'VAR_5': 'path', 'VAR_6': 'Override', 'FUNC_0': 'getRequest', 'FUNC_1': 'getData'} | java | OOP | 100.00% |
package com.krishagni.catissueplus.core.common;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
public class AttributeModifiedSupport implements Serializable {
private static final long serialVersionUID = -6538288756745006122L;
private Set<String> modifiedAttrs = new HashSet<>();
private String opComments;
public void attrModified(String attr) {
modifiedAttrs.add(attr);
}
public boolean isAttrModified(String attr) {
return modifiedAttrs.contains(attr);
}
public int modifiedAttrsCount() {
return modifiedAttrs.size();
}
public boolean areTheOnlyModifiedAttrs(String ...attrs) {
if (attrs == null) {
return modifiedAttrs.isEmpty();
}
int modified = 0;
for (String attr : attrs) {
modified += (isAttrModified(attr) ? 1 : 0);
}
return modified == modifiedAttrs.size();
}
public String getOpComments() {
return opComments;
}
public void setOpComments(String opComments) {
this.opComments = opComments;
}
}
| package IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3.IMPORT_4;
import IMPORT_5.IMPORT_6.IMPORT_7;
import IMPORT_5.IMPORT_8.HashSet;
import IMPORT_5.IMPORT_8.Set;
public class CLASS_0 implements IMPORT_7 {
private static final long VAR_0 = -6538288756745006122L;
private Set<String> VAR_1 = new HashSet<>();
private String VAR_2;
public void FUNC_0(String attr) {
VAR_1.FUNC_1(attr);
}
public boolean FUNC_2(String attr) {
return VAR_1.contains(attr);
}
public int FUNC_3() {
return VAR_1.FUNC_4();
}
public boolean FUNC_5(String ...attrs) {
if (attrs == null) {
return VAR_1.FUNC_6();
}
int VAR_3 = 0;
for (String attr : attrs) {
VAR_3 += (FUNC_2(attr) ? 1 : 0);
}
return VAR_3 == VAR_1.FUNC_4();
}
public String getOpComments() {
return VAR_2;
}
public void setOpComments(String VAR_2) {
this.VAR_2 = VAR_2;
}
}
| 0.799673 | {'IMPORT_0': 'com', 'IMPORT_1': 'krishagni', 'IMPORT_2': 'catissueplus', 'IMPORT_3': 'core', 'IMPORT_4': 'common', 'IMPORT_5': 'java', 'IMPORT_6': 'io', 'IMPORT_7': 'Serializable', 'IMPORT_8': 'util', 'CLASS_0': 'AttributeModifiedSupport', 'VAR_0': 'serialVersionUID', 'VAR_1': 'modifiedAttrs', 'VAR_2': 'opComments', 'FUNC_0': 'attrModified', 'FUNC_1': 'add', 'FUNC_2': 'isAttrModified', 'FUNC_3': 'modifiedAttrsCount', 'FUNC_4': 'size', 'FUNC_5': 'areTheOnlyModifiedAttrs', 'FUNC_6': 'isEmpty', 'VAR_3': 'modified'} | java | OOP | 77.70% |
package com.radirius.mercury.math.geometry;
import com.radirius.mercury.math.MathUtil;
/**
* A class for 2-dimensional vectors.
*
* @author wessles
*/
public class Vector2f {
public float x = 0, y = 0;
public Vector2f(float x, float y) {
this.x = x;
this.y = y;
}
public Vector2f(float theta) {
x = MathUtil.cos(theta);
y = MathUtil.sin(theta);
}
public Vector2f add(Vector2f vec) {
x += vec.x;
y += vec.y;
return this;
}
public Vector2f add(float theta) {
x += (float) Math.cos(theta);
y += (float) Math.sin(theta);
return this;
}
public Vector2f sub(Vector2f vec) {
x -= vec.x;
y -= vec.y;
return this;
}
public Vector2f sub(float theta) {
x -= MathUtil.cos(theta);
y -= MathUtil.sin(theta);
return this;
}
public Vector2f mul(Vector2f vec) {
x *= vec.x;
y *= vec.y;
return this;
}
public Vector2f div(Vector2f vec) {
x /= vec.x;
y /= vec.y;
return this;
}
public Vector2f set(float theta) {
x = (float) Math.toDegrees(Math.cos(theta));
y = (float) Math.toDegrees(Math.sin(theta));
return this;
}
public Vector2f set(Vector2f vec) {
x = vec.x;
y = vec.y;
return this;
}
public Vector2f set(float... coords) {
set(new Vector2f(coords[0], coords[1]));
return this;
}
public Vector2f scale(float amt) {
x *= amt;
y *= amt;
return this;
}
public Vector2f negate() {
scale(-1);
return this;
}
public float length() {
return (float) Math.sqrt(x * x + y * y);
}
public Vector2f normalize() {
float l = length();
x /= l;
y /= l;
return this;
}
public float dot(Vector2f vec) {
return x * vec.x + y * vec.y;
}
public float distance(Vector2f vec) {
float dx = vec.x - x;
float dy = vec.y - y;
return (float) Math.sqrt(dx * dx + dy * dy);
}
public Vector2f rotate(float angle) {
double rad = MathUtil.toRadians(angle);
double cos = MathUtil.cos((float) rad);
double sin = MathUtil.sin((float) rad);
x = (float) (x * cos - y * sin);
y = (float) (x * sin + y * cos);
return this;
}
public float theta() {
return (float) Math.toDegrees(Math.atan2(y, x));
}
public Vector2f copy() {
return new Vector2f(x, y);
}
public Vector2f setZero() {
return new Vector2f(0, 0);
}
@Override
public String toString() {
return "(" + x + ", " + y + ")";
}
public float getX() {
return x;
}
public float getY() {
return y;
}
}
| package com.IMPORT_0.IMPORT_1.math.IMPORT_2;
import com.IMPORT_0.IMPORT_1.math.MathUtil;
/**
* A class for 2-dimensional vectors.
*
* @author wessles
*/
public class CLASS_0 {
public float VAR_0 = 0, VAR_1 = 0;
public CLASS_0(float VAR_0, float VAR_1) {
this.VAR_0 = VAR_0;
this.VAR_1 = VAR_1;
}
public CLASS_0(float theta) {
VAR_0 = MathUtil.FUNC_0(theta);
VAR_1 = MathUtil.FUNC_1(theta);
}
public CLASS_0 FUNC_2(CLASS_0 vec) {
VAR_0 += vec.VAR_0;
VAR_1 += vec.VAR_1;
return this;
}
public CLASS_0 FUNC_2(float theta) {
VAR_0 += (float) VAR_4.FUNC_0(theta);
VAR_1 += (float) VAR_4.FUNC_1(theta);
return this;
}
public CLASS_0 sub(CLASS_0 vec) {
VAR_0 -= vec.VAR_0;
VAR_1 -= vec.VAR_1;
return this;
}
public CLASS_0 sub(float theta) {
VAR_0 -= MathUtil.FUNC_0(theta);
VAR_1 -= MathUtil.FUNC_1(theta);
return this;
}
public CLASS_0 mul(CLASS_0 vec) {
VAR_0 *= vec.VAR_0;
VAR_1 *= vec.VAR_1;
return this;
}
public CLASS_0 div(CLASS_0 vec) {
VAR_0 /= vec.VAR_0;
VAR_1 /= vec.VAR_1;
return this;
}
public CLASS_0 FUNC_3(float theta) {
VAR_0 = (float) VAR_4.toDegrees(VAR_4.FUNC_0(theta));
VAR_1 = (float) VAR_4.toDegrees(VAR_4.FUNC_1(theta));
return this;
}
public CLASS_0 FUNC_3(CLASS_0 vec) {
VAR_0 = vec.VAR_0;
VAR_1 = vec.VAR_1;
return this;
}
public CLASS_0 FUNC_3(float... coords) {
FUNC_3(new CLASS_0(coords[0], coords[1]));
return this;
}
public CLASS_0 scale(float amt) {
VAR_0 *= amt;
VAR_1 *= amt;
return this;
}
public CLASS_0 negate() {
scale(-1);
return this;
}
public float FUNC_4() {
return (float) VAR_4.FUNC_5(VAR_0 * VAR_0 + VAR_1 * VAR_1);
}
public CLASS_0 FUNC_6() {
float VAR_5 = FUNC_4();
VAR_0 /= VAR_5;
VAR_1 /= VAR_5;
return this;
}
public float dot(CLASS_0 vec) {
return VAR_0 * vec.VAR_0 + VAR_1 * vec.VAR_1;
}
public float distance(CLASS_0 vec) {
float VAR_6 = vec.VAR_0 - VAR_0;
float VAR_7 = vec.VAR_1 - VAR_1;
return (float) VAR_4.FUNC_5(VAR_6 * VAR_6 + VAR_7 * VAR_7);
}
public CLASS_0 FUNC_7(float angle) {
double rad = MathUtil.FUNC_8(angle);
double VAR_2 = MathUtil.FUNC_0((float) rad);
double VAR_3 = MathUtil.FUNC_1((float) rad);
VAR_0 = (float) (VAR_0 * VAR_2 - VAR_1 * VAR_3);
VAR_1 = (float) (VAR_0 * VAR_3 + VAR_1 * VAR_2);
return this;
}
public float theta() {
return (float) VAR_4.toDegrees(VAR_4.atan2(VAR_1, VAR_0));
}
public CLASS_0 FUNC_9() {
return new CLASS_0(VAR_0, VAR_1);
}
public CLASS_0 FUNC_10() {
return new CLASS_0(0, 0);
}
@VAR_8
public CLASS_1 FUNC_11() {
return "(" + VAR_0 + ", " + VAR_1 + ")";
}
public float FUNC_12() {
return VAR_0;
}
public float getY() {
return VAR_1;
}
}
| 0.504152 | {'IMPORT_0': 'radirius', 'IMPORT_1': 'mercury', 'IMPORT_2': 'geometry', 'CLASS_0': 'Vector2f', 'VAR_0': 'x', 'VAR_1': 'y', 'FUNC_0': 'cos', 'VAR_2': 'cos', 'FUNC_1': 'sin', 'VAR_3': 'sin', 'FUNC_2': 'add', 'VAR_4': 'Math', 'FUNC_3': 'set', 'FUNC_4': 'length', 'FUNC_5': 'sqrt', 'FUNC_6': 'normalize', 'VAR_5': 'l', 'VAR_6': 'dx', 'VAR_7': 'dy', 'FUNC_7': 'rotate', 'FUNC_8': 'toRadians', 'FUNC_9': 'copy', 'FUNC_10': 'setZero', 'VAR_8': 'Override', 'CLASS_1': 'String', 'FUNC_11': 'toString', 'FUNC_12': 'getX'} | java | OOP | 39.96% |
/*************************************************************************
* Parses the file and returns the contained experiment subparts.
* The subparts are returned by adding them to given lists.
*
* @param location location of the database
* @param BaseExperiment Experiment object to own the parsed subparts.
* @param need_metrics whether to read metrics or not
* @param userData user preference data
*
* @throws Exception
*
************************************************************************/
public File parse(File location, BaseExperiment experiment, boolean need_metrics, IUserData<String, String> userData)
throws Exception
{
InputStream stream;
String name = location.toString();
String directory, xmlFilePath;
if (location.isDirectory()) {
directory = location.getAbsolutePath();
xmlFilePath = directory + File.separatorChar + DatabaseManager.getDatabaseFilename("xml").orElse("");
} else {
directory = location.getParent();
xmlFilePath = location.getAbsolutePath();
}
File XMLfile = new File(xmlFilePath);
if (!XMLfile.canRead()) {
throw new IOException("File does not exist or not readable: " + XMLfile.getAbsolutePath());
}
final Builder builder;
if (need_metrics)
{
stream = new FileInputStream(XMLfile);
builder = new ExperimentBuilder2(experiment, name, userData);
}
else
{
File trace_db_file = new File(directory + File.separatorChar +
BaseExperiment.getDefaultDbTraceFilename());
if (trace_db_file.canRead()) {
stream = new FileInputStream(XMLfile);
builder = new BaseExperimentBuilder(experiment, name, userData);
} else {
String callpathLoc = directory + File.separatorChar + "callpath.xml";
File callpathFile = new File(callpathLoc);
if (!callpathFile.exists())
{
File dir = new File(directory);
if (!dir.canWrite()) {
throw new RuntimeException("Directory is not writable: " + directory);
}
Grep.grep(xmlFilePath, callpathLoc, "<M ", false);
callpathFile = new File(callpathLoc);
}
stream = new FileInputStream(callpathFile);
builder = new BaseExperimentBuilder(experiment, name, userData);
}
}
IParser parser = new Parser(name, stream, builder);
parser.parse(name);
if ( builder.getParseOK() != Builder.PARSER_OK ) {
throw new InvalExperimentException(builder.getParseErrorLineNumber());
}
return XMLfile;
} | /*************************************************************************
* Parses the file and returns the contained experiment subparts.
* The subparts are returned by adding them to given lists.
*
* @param location location of the database
* @param BaseExperiment Experiment object to own the parsed subparts.
* @param need_metrics whether to read metrics or not
* @param userData user preference data
*
* @throws Exception
*
************************************************************************/
public File FUNC_0(File location, BaseExperiment VAR_0, boolean VAR_1, IUserData<CLASS_0, CLASS_0> VAR_2)
throws Exception
{
CLASS_1 VAR_3;
CLASS_0 VAR_4 = location.FUNC_1();
CLASS_0 VAR_5, xmlFilePath;
if (location.FUNC_2()) {
VAR_5 = location.getAbsolutePath();
xmlFilePath = VAR_5 + File.VAR_6 + VAR_7.FUNC_3("xml").orElse("");
} else {
VAR_5 = location.getParent();
xmlFilePath = location.getAbsolutePath();
}
File VAR_8 = new File(xmlFilePath);
if (!VAR_8.FUNC_4()) {
throw new CLASS_2("File does not exist or not readable: " + VAR_8.getAbsolutePath());
}
final CLASS_3 VAR_10;
if (VAR_1)
{
VAR_3 = new CLASS_4(VAR_8);
VAR_10 = new CLASS_5(VAR_0, VAR_4, VAR_2);
}
else
{
File VAR_11 = new File(VAR_5 + File.VAR_6 +
BaseExperiment.getDefaultDbTraceFilename());
if (VAR_11.FUNC_4()) {
VAR_3 = new CLASS_4(VAR_8);
VAR_10 = new BaseExperimentBuilder(VAR_0, VAR_4, VAR_2);
} else {
CLASS_0 callpathLoc = VAR_5 + File.VAR_6 + "callpath.xml";
File VAR_12 = new File(callpathLoc);
if (!VAR_12.FUNC_5())
{
File VAR_13 = new File(VAR_5);
if (!VAR_13.FUNC_6()) {
throw new CLASS_6("Directory is not writable: " + VAR_5);
}
VAR_14.FUNC_7(xmlFilePath, callpathLoc, "<M ", false);
VAR_12 = new File(callpathLoc);
}
VAR_3 = new CLASS_4(VAR_12);
VAR_10 = new BaseExperimentBuilder(VAR_0, VAR_4, VAR_2);
}
}
CLASS_7 parser = new CLASS_8(VAR_4, VAR_3, VAR_10);
parser.FUNC_0(VAR_4);
if ( VAR_10.getParseOK() != VAR_9.PARSER_OK ) {
throw new CLASS_9(VAR_10.FUNC_8());
}
return VAR_8;
} | 0.659805 | {'FUNC_0': 'parse', 'VAR_0': 'experiment', 'VAR_1': 'need_metrics', 'CLASS_0': 'String', 'VAR_2': 'userData', 'CLASS_1': 'InputStream', 'VAR_3': 'stream', 'VAR_4': 'name', 'FUNC_1': 'toString', 'VAR_5': 'directory', 'FUNC_2': 'isDirectory', 'VAR_6': 'separatorChar', 'VAR_7': 'DatabaseManager', 'FUNC_3': 'getDatabaseFilename', 'VAR_8': 'XMLfile', 'FUNC_4': 'canRead', 'CLASS_2': 'IOException', 'CLASS_3': 'Builder', 'VAR_9': 'Builder', 'VAR_10': 'builder', 'CLASS_4': 'FileInputStream', 'CLASS_5': 'ExperimentBuilder2', 'VAR_11': 'trace_db_file', 'VAR_12': 'callpathFile', 'FUNC_5': 'exists', 'VAR_13': 'dir', 'FUNC_6': 'canWrite', 'CLASS_6': 'RuntimeException', 'VAR_14': 'Grep', 'FUNC_7': 'grep', 'CLASS_7': 'IParser', 'CLASS_8': 'Parser', 'CLASS_9': 'InvalExperimentException', 'FUNC_8': 'getParseErrorLineNumber'} | java | Procedural | 21.41% |
/**
* close ble connection
*
* @param data data
* @param reply reply
* @param option option
* @return boolean
*/
public boolean closeBleConnection(MessageParcel data, MessageParcel reply, MessageOption option) {
String dataString = data.readString();
LogUtils.info("dataString:" + dataString);
ZSONObject dataObject = ZSONObject.stringToZSON(dataString);
String deviceId = String.valueOf(dataObject.get(DEVICE_ID));
if (TextUtils.isEmpty(deviceId)) {
LogUtils.info("deviceId can not be null");
return true;
}
String errorCode = BleHelper.getInstance().closeBleConnection(deviceId);
return replyResult(reply, option, parseErrorCode(errorCode), new HashMap<>());
} | /**
* close ble connection
*
* @param data data
* @param reply reply
* @param option option
* @return boolean
*/
public boolean FUNC_0(CLASS_0 VAR_0, CLASS_0 VAR_1, CLASS_1 VAR_2) {
CLASS_2 VAR_4 = VAR_0.FUNC_1();
VAR_5.FUNC_2("dataString:" + VAR_4);
CLASS_3 VAR_7 = VAR_6.FUNC_3(VAR_4);
CLASS_2 VAR_8 = VAR_3.FUNC_4(VAR_7.FUNC_5(VAR_9));
if (VAR_10.FUNC_6(VAR_8)) {
VAR_5.FUNC_2("deviceId can not be null");
return true;
}
CLASS_2 VAR_11 = VAR_12.FUNC_7().FUNC_0(VAR_8);
return FUNC_8(VAR_1, VAR_2, FUNC_9(VAR_11), new CLASS_4<>());
} | 0.982406 | {'FUNC_0': 'closeBleConnection', 'CLASS_0': 'MessageParcel', 'VAR_0': 'data', 'VAR_1': 'reply', 'CLASS_1': 'MessageOption', 'VAR_2': 'option', 'CLASS_2': 'String', 'VAR_3': 'String', 'VAR_4': 'dataString', 'FUNC_1': 'readString', 'VAR_5': 'LogUtils', 'FUNC_2': 'info', 'CLASS_3': 'ZSONObject', 'VAR_6': 'ZSONObject', 'VAR_7': 'dataObject', 'FUNC_3': 'stringToZSON', 'VAR_8': 'deviceId', 'FUNC_4': 'valueOf', 'FUNC_5': 'get', 'VAR_9': 'DEVICE_ID', 'VAR_10': 'TextUtils', 'FUNC_6': 'isEmpty', 'VAR_11': 'errorCode', 'VAR_12': 'BleHelper', 'FUNC_7': 'getInstance', 'FUNC_8': 'replyResult', 'FUNC_9': 'parseErrorCode', 'CLASS_4': 'HashMap'} | java | Procedural | 54.17% |
/**
* Concatenates a series of arrays.
*
* @param arrays List of arrays
* @return Concatenated array
*/
public static double[] concatenate(double[]... arrays)
{
List<Double> list = new LinkedList<Double>();
for (double[] array : arrays)
list.addAll(toList(array));
double[] concatArray = toArray(list);
return concatArray;
} | /**
* Concatenates a series of arrays.
*
* @param arrays List of arrays
* @return Concatenated array
*/
public static double[] FUNC_0(double[]... VAR_0)
{
List<Double> list = new LinkedList<Double>();
for (double[] VAR_1 : VAR_0)
list.FUNC_1(FUNC_2(VAR_1));
double[] VAR_2 = FUNC_3(list);
return VAR_2;
} | 0.603835 | {'FUNC_0': 'concatenate', 'VAR_0': 'arrays', 'VAR_1': 'array', 'FUNC_1': 'addAll', 'FUNC_2': 'toList', 'VAR_2': 'concatArray', 'FUNC_3': 'toArray'} | java | Procedural | 77.36% |
/**
* transaction factory
*
* @author happyyangyuan
*/
public final class TransactionFactory {
/**
* create or get the current xian transaction.
* This method is always returning a transaction reference for you.
*
* @param transactionId transaction id
* @param readOnly boolean flag indicates that whether this dao operation is read-only
* @return the deferred transaction reference.
*/
public static Single<XianTransaction> getTransaction(String transactionId, boolean readOnly) {
if (BaseLocalTransaction.getExistedLocalTrans(transactionId) != null) {
return Single.just(BaseLocalTransaction.getExistedLocalTrans(transactionId));
}
if (readOnly) {
return PoolFactory.getPool().getSlaveDatasource().getConnection()
.map(connection -> connection.createTransaction(transactionId));
} else {
return PoolFactory.getPool().getMasterDatasource().getConnection()
.map(connection -> connection.createTransaction(transactionId));
}
}
/**
* create or get the current xian transaction
*
* @param transactionId transaction id
* @return the current transaction reference
*/
public static Single<XianTransaction> getTransaction(String transactionId) {
return getTransaction(transactionId, false);
}
} | /**
* transaction factory
*
* @author happyyangyuan
*/
public final class CLASS_0 {
/**
* create or get the current xian transaction.
* This method is always returning a transaction reference for you.
*
* @param transactionId transaction id
* @param readOnly boolean flag indicates that whether this dao operation is read-only
* @return the deferred transaction reference.
*/
public static CLASS_1<CLASS_2> FUNC_0(CLASS_3 VAR_1, boolean VAR_2) {
if (VAR_3.FUNC_1(VAR_1) != null) {
return VAR_0.FUNC_2(VAR_3.FUNC_1(VAR_1));
}
if (VAR_2) {
return VAR_4.FUNC_3().getSlaveDatasource().FUNC_4()
.FUNC_5(VAR_5 -> VAR_5.FUNC_6(VAR_1));
} else {
return VAR_4.FUNC_3().FUNC_7().FUNC_4()
.FUNC_5(VAR_5 -> VAR_5.FUNC_6(VAR_1));
}
}
/**
* create or get the current xian transaction
*
* @param transactionId transaction id
* @return the current transaction reference
*/
public static CLASS_1<CLASS_2> FUNC_0(CLASS_3 VAR_1) {
return FUNC_0(VAR_1, false);
}
} | 0.986817 | {'CLASS_0': 'TransactionFactory', 'CLASS_1': 'Single', 'VAR_0': 'Single', 'CLASS_2': 'XianTransaction', 'FUNC_0': 'getTransaction', 'CLASS_3': 'String', 'VAR_1': 'transactionId', 'VAR_2': 'readOnly', 'VAR_3': 'BaseLocalTransaction', 'FUNC_1': 'getExistedLocalTrans', 'FUNC_2': 'just', 'VAR_4': 'PoolFactory', 'FUNC_3': 'getPool', 'FUNC_4': 'getConnection', 'FUNC_5': 'map', 'VAR_5': 'connection', 'FUNC_6': 'createTransaction', 'FUNC_7': 'getMasterDatasource'} | java | OOP | 39.39% |
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.github.sonofmath.hello;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
/**
*
* @author sonofmath
*/
public class HelloWorldTest {
public HelloWorldTest() {
System.out.println("this is a test");
}
/* just a comment to test*/
@BeforeClass
public static void setUpClass() {
}
@AfterClass
public static void tearDownClass() {
}
@Before
public void setUp() {
}
@After
public void tearDown() {
}
/**
* Test of setMessage method, of class HelloWorld.
*/
@Test
public void testSetMessage() {
System.out.println("setMessage");
String _message = "this is a test";
HelloWorld instance = new HelloWorld();
assertEquals("", instance.getMessage());
instance.setMessage(_message);
assertEquals(_message, instance.getMessage());
}
@Test(expected = UnsupportedOperationException.class)
public void testSetMessageNull() {
System.out.println("setMessage");
String _message = null;
HelloWorld instance = new HelloWorld();
assertEquals("", instance.getMessage());
instance.setMessage(_message);
assertEquals(_message, instance.getMessage());
}
/**
* Test of getMessage method, of class HelloWorld.
*/
@Test
public void testGetMessage() {
System.out.println("getMessage");
HelloWorld instance = new HelloWorld();
String expResult = "";
String result = instance.getMessage();
assertEquals(expResult, result);
}
}
| /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package IMPORT_0.IMPORT_1.IMPORT_2.hello;
import IMPORT_3.IMPORT_4.After;
import IMPORT_3.IMPORT_4.IMPORT_5;
import IMPORT_3.IMPORT_4.IMPORT_6;
import IMPORT_3.IMPORT_4.BeforeClass;
import IMPORT_3.IMPORT_4.IMPORT_7;
import static IMPORT_3.IMPORT_4.IMPORT_8.*;
/**
*
* @author sonofmath
*/
public class CLASS_0 {
public CLASS_0() {
VAR_0.VAR_1.FUNC_0("this is a test");
}
/* just a comment to test*/
@BeforeClass
public static void FUNC_1() {
}
@IMPORT_5
public static void FUNC_2() {
}
@IMPORT_6
public void FUNC_3() {
}
@After
public void FUNC_4() {
}
/**
* Test of setMessage method, of class HelloWorld.
*/
@IMPORT_7
public void FUNC_5() {
VAR_0.VAR_1.FUNC_0("setMessage");
String VAR_2 = "this is a test";
CLASS_1 VAR_3 = new CLASS_1();
FUNC_6("", VAR_3.FUNC_7());
VAR_3.FUNC_8(VAR_2);
FUNC_6(VAR_2, VAR_3.FUNC_7());
}
@IMPORT_7(VAR_4 = CLASS_2.class)
public void FUNC_9() {
VAR_0.VAR_1.FUNC_0("setMessage");
String VAR_2 = null;
CLASS_1 VAR_3 = new CLASS_1();
FUNC_6("", VAR_3.FUNC_7());
VAR_3.FUNC_8(VAR_2);
FUNC_6(VAR_2, VAR_3.FUNC_7());
}
/**
* Test of getMessage method, of class HelloWorld.
*/
@IMPORT_7
public void FUNC_10() {
VAR_0.VAR_1.FUNC_0("getMessage");
CLASS_1 VAR_3 = new CLASS_1();
String VAR_5 = "";
String result = VAR_3.FUNC_7();
FUNC_6(VAR_5, result);
}
}
| 0.884412 | {'IMPORT_0': 'com', 'IMPORT_1': 'github', 'IMPORT_2': 'sonofmath', 'IMPORT_3': 'org', 'IMPORT_4': 'junit', 'IMPORT_5': 'AfterClass', 'IMPORT_6': 'Before', 'IMPORT_7': 'Test', 'IMPORT_8': 'Assert', 'CLASS_0': 'HelloWorldTest', 'VAR_0': 'System', 'VAR_1': 'out', 'FUNC_0': 'println', 'FUNC_1': 'setUpClass', 'FUNC_2': 'tearDownClass', 'FUNC_3': 'setUp', 'FUNC_4': 'tearDown', 'FUNC_5': 'testSetMessage', 'VAR_2': '_message', 'CLASS_1': 'HelloWorld', 'VAR_3': 'instance', 'FUNC_6': 'assertEquals', 'FUNC_7': 'getMessage', 'FUNC_8': 'setMessage', 'VAR_4': 'expected', 'CLASS_2': 'UnsupportedOperationException', 'FUNC_9': 'testSetMessageNull', 'FUNC_10': 'testGetMessage', 'VAR_5': 'expResult'} | java | OOP | 58.30% |
/**
* Resolves types in this signature given a context type.
*
* @param context a context type
* @return a new signature with return and parameter types resolved
*
* @see Types#resolveType(Type, Type)
*/
public GenericSignature resolve(Type context) {
Type[] newParams = new Type[parameterTypes.length];
for (int i = 0; i < parameterTypes.length; i++) {
newParams[i] = resolveType(context, parameterTypes[i]);
}
return new GenericSignature(name, resolveType(context, returnType), typeVariables, newParams);
} | /**
* Resolves types in this signature given a context type.
*
* @param context a context type
* @return a new signature with return and parameter types resolved
*
* @see Types#resolveType(Type, Type)
*/
public CLASS_0 FUNC_0(Type context) {
Type[] newParams = new Type[VAR_0.length];
for (int i = 0; i < VAR_0.length; i++) {
newParams[i] = resolveType(context, VAR_0[i]);
}
return new CLASS_0(name, resolveType(context, VAR_1), typeVariables, newParams);
} | 0.415819 | {'CLASS_0': 'GenericSignature', 'FUNC_0': 'resolve', 'VAR_0': 'parameterTypes', 'VAR_1': 'returnType'} | java | Procedural | 91.03% |
import java.awt.Paint;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
public class Main {
boolean[] isPrime;
int IS_PRIME_COUNT = 1000000;
public static void main(String[] args) throws Exception {
new Main();
}
public Main() throws Exception {
// Scanner sc = new Scanner(new FileReader("input.txt"));
Scanner sc = new Scanner(System.in);
// ArrayList<ArrayList<Integer>> l;
// ArrayList<Integer> toPermute = new ArrayList<>();
// toPermute.add(1);
// toPermute.add(2);
// toPermute.add(4);
// toPermute.add(5);
// toPermute.add(6);
// populateIsPrime();
// System.out.println(allPosibleSubstring("abc"));
// System.out.println(findAllSubsets(toPermute));
// printArr(getCharsCount("aabbc"));
String s = sc.next();
int [] charsCount = getCharsCountBig(s);
int Bs = charsCount['B'];
int us = charsCount['u'] / 2;//2
int ls = charsCount['l'];
int bs = charsCount['b'];
int as = charsCount['a'] / 2;//2
int ss = charsCount['s'];
int rs = charsCount['r'];
int m = s.length();
m = Math.min(m, Bs);
m = Math.min(m, us);
m = Math.min(m, ls);
m = Math.min(m, bs);
m = Math.min(m, as);
m = Math.min(m, ss);
m = Math.min(m, rs);
System.out.println(m);
sc.close();
}
// helpers
static void printArr(int [] arrr){
System.out.print("[");
for (int i=0;i<arrr.length;i++){
System.out.print(arrr[i] + ",");
}
System.out.print("]");
}
static void permute(ArrayList<Integer> a, int k, List<ArrayList<Integer>> result)
{
if (k == a.size())
{
ArrayList<Integer> onePermutation = new ArrayList<>(a.size());
for (int i = 0; i < a.size(); i++)
{
onePermutation.add(a.get(i));
// System.out.print(" [" + a.get(i) + "] ");
}
// System.out.println();
result.add(onePermutation);
}
else
{
for (int i = k; i < a.size(); i++)
{
int temp = a.get(k);
a.set(k, a.get(i));
a.set(i, temp);
permute(a, k + 1,result);
temp = a.get(k);
a.set(k, a.get(i));
a.set(i, temp);
}
}
}
static void permute(String a, int k, List<String> result)
{
if (k == a.length())
{
String onePermutation = new String(a);
result.add(onePermutation);
}
else
{
char[] charArr = a.toCharArray();
for (int i = k; i < charArr.length; i++)
{
char temp = charArr[k];
charArr[k] = charArr[i];
charArr[i] = temp;
permute(new String(charArr), k + 1,result);
}
}
}
static ArrayList<ArrayList<Integer>> circularPermute(ArrayList<Integer> a){
ArrayList<ArrayList<Integer>> result = new ArrayList<>(a.size());
ArrayList<Integer> b = new ArrayList<>(a);
for (int i=0;i<a.size();i++){
int tmp = b.get(b.size() - 1);
b.add(0, tmp);
b.remove(b.size() - 1);
ArrayList<Integer> onePerm = new ArrayList<>(b);
result.add(onePerm);
}
return result;
}
static ArrayList<String> circularPermute(String a){
ArrayList<String> result = new ArrayList<>(a.length());
String b = new String(a);
for (int i=0;i<a.length();i++){
char tmp = b.charAt(b.length() - 1);
b = tmp + "" + b;
b = b.substring(0, b.length() - 1);
String onePerm = new String(b);
result.add(onePerm);
}
return result;
}
public int binarySearch(ArrayList<Integer> a, int toFind){
int low = 0;
int high = a.size() - 1;
int mid = -1;
while (low <= high){
mid = low + (high - low) / 2;
if (a.get(mid) == toFind){
return mid;
}
if (a.get(mid) < toFind){
low = mid + 1;
} else {
high = mid - 1;
}
}
return -1;
}
public void printArrayList(ArrayList<Integer> a){
for (int i=0;i<a.size();i++){
System.out.print(a.get(i) + " ");
}
System.out.println();
}
public void populateIsPrime(){
// initially assume all integers are prime
isPrime = new boolean[IS_PRIME_COUNT + 1];
for (int i = 2; i <= IS_PRIME_COUNT; i++) {
isPrime[i] = true;
}
for (int factor = 2; factor*factor <= IS_PRIME_COUNT; factor++) {
if (isPrime[factor]) {
for (int j = factor; factor*j <= IS_PRIME_COUNT; j++) {
isPrime[factor*j] = false;
}
}
}
}
static long gcd(long a, long b)
{
while (b > 0)
{
long temp = b;
b = a % b; // % is remainder
a = temp;
}
return a;
}
static long gcd(long[] input)
{
long result = input[0];
for(int i = 1; i < input.length; i++) result = gcd(result, input[i]);
return result;
}
static long lcm(long a, long b)
{
return a * (b / gcd(a, b));
}
static long lcm(long[] input)
{
long result = input[0];
for(int i = 1; i < input.length; i++) result = lcm(result, input[i]);
return result;
}
static ArrayList<String> allPosibleSubstring(String str){
ArrayList<String> res = new ArrayList<>();
for(int c = 0 ; c < str.length() ; c++ )
{
for(int i = 1 ; i <= str.length() - c ; i++ )
{
String sub = str.substring(c, c+i);
res.add(sub);
}
}
return res;
}
private ArrayList<Integer> cloneSet(ArrayList<Integer> input)
{
ArrayList<Integer> clone = new ArrayList<>();
for (int i = 0; i < input.size(); i++)
{
clone.add(input.get(i));
}
return clone;
}
public void findAllSubsets(ArrayList<ArrayList<Integer>> allSubsets, ArrayList<Integer>set, int currIndex)
{
// base case: if all elements of given set are considered for all possible subsets
if (currIndex == set.size())
{
return;
}
// need to get the size in advance
// since adding new sets to allSubsets will increase its size dynamically.
int allSubSetsSize = allSubsets.size();
ArrayList<Integer> newSet;
// for each set - allSubsets[i] in allSubsets:
// 1. create new set by adding element placed at 'currIndex' in the given set
// 2. add this newly created set to 'allSubsets'
for (int i = 0; i < allSubSetsSize; i++)
{
newSet = cloneSet(allSubsets.get(i));
newSet.add(set.get(currIndex));
allSubsets.add(newSet);
}
// include next element from given set in allSubsets
findAllSubsets(allSubsets, set, currIndex+1);
}
public ArrayList<ArrayList<Integer>> findAllSubsets(ArrayList<Integer> set)
{
ArrayList<ArrayList<Integer>> allSubsets = new ArrayList<>();
// add empty set to all possible subsets
allSubsets.add(new ArrayList<Integer>());
// use empty set to generate all possible subsets of given set using recursion
findAllSubsets(allSubsets, set, 0);
return allSubsets;
}
public int[] getCharsCount(String str){
int[] res= new int[26];
for (int i=0;i<26;i++){
res[i] = 0;
}
for (int i=0;i<str.length();i++){
int pos = str.charAt(i) - 'a';
res[pos] = res[pos] + 1;
}
return res;
}
public int[] getCharsCountBig(String str){
int[] res= new int[256];
for (int i=0;i<256;i++){
res[i] = 0;
}
for (int i=0;i<str.length();i++){
int pos = str.charAt(i);
res[pos] = res[pos] + 1;
}
return res;
}
}
| import java.awt.Paint;
import java.io.IMPORT_0;
import java.io.IMPORT_1;
import java.io.IMPORT_2;
import java.io.FileReader;
import java.io.IMPORT_3;
import java.util.IMPORT_4;
import java.util.IMPORT_5;
import java.util.IMPORT_6;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.IMPORT_7;
import java.util.Scanner;
public class Main {
boolean[] VAR_0;
int IS_PRIME_COUNT = 1000000;
public static void FUNC_0(CLASS_0[] VAR_1) throws CLASS_1 {
new Main();
}
public Main() throws CLASS_1 {
// Scanner sc = new Scanner(new FileReader("input.txt"));
Scanner sc = new Scanner(System.in);
// ArrayList<ArrayList<Integer>> l;
// ArrayList<Integer> toPermute = new ArrayList<>();
// toPermute.add(1);
// toPermute.add(2);
// toPermute.add(4);
// toPermute.add(5);
// toPermute.add(6);
// populateIsPrime();
// System.out.println(allPosibleSubstring("abc"));
// System.out.println(findAllSubsets(toPermute));
// printArr(getCharsCount("aabbc"));
CLASS_0 VAR_2 = sc.FUNC_1();
int [] charsCount = getCharsCountBig(VAR_2);
int VAR_3 = charsCount['B'];
int us = charsCount['u'] / 2;//2
int ls = charsCount['l'];
int bs = charsCount['b'];
int as = charsCount['a'] / 2;//2
int VAR_4 = charsCount['s'];
int VAR_5 = charsCount['r'];
int m = VAR_2.length();
m = VAR_6.min(m, VAR_3);
m = VAR_6.min(m, us);
m = VAR_6.min(m, ls);
m = VAR_6.min(m, bs);
m = VAR_6.min(m, as);
m = VAR_6.min(m, VAR_4);
m = VAR_6.min(m, VAR_5);
System.out.println(m);
sc.close();
}
// helpers
static void printArr(int [] VAR_7){
System.out.FUNC_2("[");
for (int i=0;i<VAR_7.length;i++){
System.out.FUNC_2(VAR_7[i] + ",");
}
System.out.FUNC_2("]");
}
static void FUNC_3(IMPORT_4<Integer> a, int VAR_8, IMPORT_7<IMPORT_4<Integer>> result)
{
if (VAR_8 == a.size())
{
IMPORT_4<Integer> VAR_9 = new IMPORT_4<>(a.size());
for (int i = 0; i < a.size(); i++)
{
VAR_9.add(a.FUNC_4(i));
// System.out.print(" [" + a.get(i) + "] ");
}
// System.out.println();
result.add(VAR_9);
}
else
{
for (int i = VAR_8; i < a.size(); i++)
{
int VAR_10 = a.FUNC_4(VAR_8);
a.set(VAR_8, a.FUNC_4(i));
a.set(i, VAR_10);
FUNC_3(a, VAR_8 + 1,result);
VAR_10 = a.FUNC_4(VAR_8);
a.set(VAR_8, a.FUNC_4(i));
a.set(i, VAR_10);
}
}
}
static void FUNC_3(CLASS_0 a, int VAR_8, IMPORT_7<CLASS_0> result)
{
if (VAR_8 == a.length())
{
CLASS_0 VAR_9 = new CLASS_0(a);
result.add(VAR_9);
}
else
{
char[] charArr = a.toCharArray();
for (int i = VAR_8; i < charArr.length; i++)
{
char VAR_10 = charArr[VAR_8];
charArr[VAR_8] = charArr[i];
charArr[i] = VAR_10;
FUNC_3(new CLASS_0(charArr), VAR_8 + 1,result);
}
}
}
static IMPORT_4<IMPORT_4<Integer>> circularPermute(IMPORT_4<Integer> a){
IMPORT_4<IMPORT_4<Integer>> result = new IMPORT_4<>(a.size());
IMPORT_4<Integer> b = new IMPORT_4<>(a);
for (int i=0;i<a.size();i++){
int tmp = b.FUNC_4(b.size() - 1);
b.add(0, tmp);
b.remove(b.size() - 1);
IMPORT_4<Integer> onePerm = new IMPORT_4<>(b);
result.add(onePerm);
}
return result;
}
static IMPORT_4<CLASS_0> circularPermute(CLASS_0 a){
IMPORT_4<CLASS_0> result = new IMPORT_4<>(a.length());
CLASS_0 b = new CLASS_0(a);
for (int i=0;i<a.length();i++){
char tmp = b.charAt(b.length() - 1);
b = tmp + "" + b;
b = b.substring(0, b.length() - 1);
CLASS_0 onePerm = new CLASS_0(b);
result.add(onePerm);
}
return result;
}
public int binarySearch(IMPORT_4<Integer> a, int VAR_11){
int low = 0;
int high = a.size() - 1;
int mid = -1;
while (low <= high){
mid = low + (high - low) / 2;
if (a.FUNC_4(mid) == VAR_11){
return mid;
}
if (a.FUNC_4(mid) < VAR_11){
low = mid + 1;
} else {
high = mid - 1;
}
}
return -1;
}
public void printArrayList(IMPORT_4<Integer> a){
for (int i=0;i<a.size();i++){
System.out.FUNC_2(a.FUNC_4(i) + " ");
}
System.out.println();
}
public void FUNC_5(){
// initially assume all integers are prime
VAR_0 = new boolean[IS_PRIME_COUNT + 1];
for (int i = 2; i <= IS_PRIME_COUNT; i++) {
VAR_0[i] = true;
}
for (int factor = 2; factor*factor <= IS_PRIME_COUNT; factor++) {
if (VAR_0[factor]) {
for (int j = factor; factor*j <= IS_PRIME_COUNT; j++) {
VAR_0[factor*j] = false;
}
}
}
}
static long FUNC_6(long a, long b)
{
while (b > 0)
{
long VAR_10 = b;
b = a % b; // % is remainder
a = VAR_10;
}
return a;
}
static long FUNC_6(long[] VAR_12)
{
long result = VAR_12[0];
for(int i = 1; i < VAR_12.length; i++) result = FUNC_6(result, VAR_12[i]);
return result;
}
static long FUNC_7(long a, long b)
{
return a * (b / FUNC_6(a, b));
}
static long FUNC_7(long[] VAR_12)
{
long result = VAR_12[0];
for(int i = 1; i < VAR_12.length; i++) result = FUNC_7(result, VAR_12[i]);
return result;
}
static IMPORT_4<CLASS_0> FUNC_8(CLASS_0 str){
IMPORT_4<CLASS_0> VAR_13 = new IMPORT_4<>();
for(int c = 0 ; c < str.length() ; c++ )
{
for(int i = 1 ; i <= str.length() - c ; i++ )
{
CLASS_0 sub = str.substring(c, c+i);
VAR_13.add(sub);
}
}
return VAR_13;
}
private IMPORT_4<Integer> FUNC_9(IMPORT_4<Integer> VAR_12)
{
IMPORT_4<Integer> clone = new IMPORT_4<>();
for (int i = 0; i < VAR_12.size(); i++)
{
clone.add(VAR_12.FUNC_4(i));
}
return clone;
}
public void findAllSubsets(IMPORT_4<IMPORT_4<Integer>> allSubsets, IMPORT_4<Integer>set, int currIndex)
{
// base case: if all elements of given set are considered for all possible subsets
if (currIndex == set.size())
{
return;
}
// need to get the size in advance
// since adding new sets to allSubsets will increase its size dynamically.
int allSubSetsSize = allSubsets.size();
IMPORT_4<Integer> VAR_14;
// for each set - allSubsets[i] in allSubsets:
// 1. create new set by adding element placed at 'currIndex' in the given set
// 2. add this newly created set to 'allSubsets'
for (int i = 0; i < allSubSetsSize; i++)
{
VAR_14 = FUNC_9(allSubsets.FUNC_4(i));
VAR_14.add(set.FUNC_4(currIndex));
allSubsets.add(VAR_14);
}
// include next element from given set in allSubsets
findAllSubsets(allSubsets, set, currIndex+1);
}
public IMPORT_4<IMPORT_4<Integer>> findAllSubsets(IMPORT_4<Integer> set)
{
IMPORT_4<IMPORT_4<Integer>> allSubsets = new IMPORT_4<>();
// add empty set to all possible subsets
allSubsets.add(new IMPORT_4<Integer>());
// use empty set to generate all possible subsets of given set using recursion
findAllSubsets(allSubsets, set, 0);
return allSubsets;
}
public int[] getCharsCount(CLASS_0 str){
int[] VAR_13= new int[26];
for (int i=0;i<26;i++){
VAR_13[i] = 0;
}
for (int i=0;i<str.length();i++){
int pos = str.charAt(i) - 'a';
VAR_13[pos] = VAR_13[pos] + 1;
}
return VAR_13;
}
public int[] getCharsCountBig(CLASS_0 str){
int[] VAR_13= new int[256];
for (int i=0;i<256;i++){
VAR_13[i] = 0;
}
for (int i=0;i<str.length();i++){
int pos = str.charAt(i);
VAR_13[pos] = VAR_13[pos] + 1;
}
return VAR_13;
}
}
| 0.361248 | {'IMPORT_0': 'BufferedReader', 'IMPORT_1': 'BufferedWriter', 'IMPORT_2': 'File', 'IMPORT_3': 'FileWriter', 'IMPORT_4': 'ArrayList', 'IMPORT_5': 'Arrays', 'IMPORT_6': 'Collections', 'IMPORT_7': 'List', 'VAR_0': 'isPrime', 'FUNC_0': 'main', 'CLASS_0': 'String', 'VAR_1': 'args', 'CLASS_1': 'Exception', 'VAR_2': 's', 'FUNC_1': 'next', 'VAR_3': 'Bs', 'VAR_4': 'ss', 'VAR_5': 'rs', 'VAR_6': 'Math', 'VAR_7': 'arrr', 'FUNC_2': 'print', 'FUNC_3': 'permute', 'VAR_8': 'k', 'VAR_9': 'onePermutation', 'FUNC_4': 'get', 'VAR_10': 'temp', 'VAR_11': 'toFind', 'FUNC_5': 'populateIsPrime', 'FUNC_6': 'gcd', 'VAR_12': 'input', 'FUNC_7': 'lcm', 'FUNC_8': 'allPosibleSubstring', 'VAR_13': 'res', 'FUNC_9': 'cloneSet', 'VAR_14': 'newSet'} | java | OOP | 7.19% |
begin_unit|revision:0.9.5;language:Java;cregit-version:0.0.1
begin_comment
comment|/* * 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. */
end_comment
begin_package
DECL|package|org.apache.camel.dataformat.bindy.csv
package|package
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|dataformat
operator|.
name|bindy
operator|.
name|csv
package|;
end_package
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|EndpointInject
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|Exchange
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|Processor
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|Produce
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|ProducerTemplate
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|builder
operator|.
name|RouteBuilder
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|component
operator|.
name|mock
operator|.
name|MockEndpoint
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|dataformat
operator|.
name|bindy
operator|.
name|annotation
operator|.
name|CsvRecord
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|dataformat
operator|.
name|bindy
operator|.
name|annotation
operator|.
name|DataField
import|;
end_import
begin_import
import|import
name|org
operator|.
name|junit
operator|.
name|Test
import|;
end_import
begin_import
import|import
name|org
operator|.
name|springframework
operator|.
name|test
operator|.
name|annotation
operator|.
name|DirtiesContext
import|;
end_import
begin_import
import|import
name|org
operator|.
name|springframework
operator|.
name|test
operator|.
name|context
operator|.
name|ContextConfiguration
import|;
end_import
begin_import
import|import
name|org
operator|.
name|springframework
operator|.
name|test
operator|.
name|context
operator|.
name|junit4
operator|.
name|AbstractJUnit4SpringContextTests
import|;
end_import
begin_class
annotation|@
name|ContextConfiguration
DECL|class|BindyCsvSkipFieldTest
specifier|public
class|class
name|BindyCsvSkipFieldTest
extends|extends
name|AbstractJUnit4SpringContextTests
block|{
DECL|field|URI_MOCK_RESULT
specifier|private
specifier|static
specifier|final
name|String
name|URI_MOCK_RESULT
init|=
literal|"mock:result"
decl_stmt|;
DECL|field|URI_DIRECT_START
specifier|private
specifier|static
specifier|final
name|String
name|URI_DIRECT_START
init|=
literal|"direct:start"
decl_stmt|;
DECL|field|input
specifier|private
specifier|static
name|String
name|input
init|=
literal|"VOA,12 abc street,Skip Street,Melbourne,VIC,3000,Australia,Skip dummy1,end of record"
decl_stmt|;
annotation|@
name|Produce
argument_list|(
name|URI_DIRECT_START
argument_list|)
DECL|field|template
specifier|private
name|ProducerTemplate
name|template
decl_stmt|;
annotation|@
name|EndpointInject
argument_list|(
name|URI_MOCK_RESULT
argument_list|)
DECL|field|result
specifier|private
name|MockEndpoint
name|result
decl_stmt|;
annotation|@
name|Test
annotation|@
name|DirtiesContext
DECL|method|testUnMarshalAndMarshal ()
specifier|public
name|void
name|testUnMarshalAndMarshal
parameter_list|()
throws|throws
name|Exception
block|{
name|template
operator|.
name|sendBody
argument_list|(
name|input
argument_list|)
expr_stmt|;
name|result
operator|.
name|expectedMessageCount
argument_list|(
literal|1
argument_list|)
expr_stmt|;
name|result
operator|.
name|assertIsSatisfied
argument_list|()
expr_stmt|;
block|}
DECL|class|ContextConfig
specifier|public
specifier|static
class|class
name|ContextConfig
extends|extends
name|RouteBuilder
block|{
DECL|field|camelDataFormat
name|BindyCsvDataFormat
name|camelDataFormat
init|=
operator|new
name|BindyCsvDataFormat
argument_list|(
name|CsvSkipField
operator|.
name|class
argument_list|)
decl_stmt|;
annotation|@
name|Override
DECL|method|configure ()
specifier|public
name|void
name|configure
parameter_list|()
block|{
name|from
argument_list|(
name|URI_DIRECT_START
argument_list|)
operator|.
name|unmarshal
argument_list|(
name|camelDataFormat
argument_list|)
operator|.
name|process
argument_list|(
operator|new
name|Processor
argument_list|()
block|{
annotation|@
name|Override
specifier|public
name|void
name|process
parameter_list|(
name|Exchange
name|exchange
parameter_list|)
throws|throws
name|Exception
block|{
name|CsvSkipField
name|csvSkipField
init|=
operator|(
name|CsvSkipField
operator|)
name|exchange
operator|.
name|getIn
argument_list|()
operator|.
name|getBody
argument_list|()
decl_stmt|;
assert|assert
name|csvSkipField
operator|.
name|getAttention
argument_list|()
operator|.
name|equals
argument_list|(
literal|"VOA"
argument_list|)
assert|;
assert|assert
name|csvSkipField
operator|.
name|getAddressLine1
argument_list|()
operator|.
name|equals
argument_list|(
literal|"12 abc street"
argument_list|)
assert|;
assert|assert
name|csvSkipField
operator|.
name|getCity
argument_list|()
operator|.
name|equals
argument_list|(
literal|"Melbourne"
argument_list|)
assert|;
assert|assert
name|csvSkipField
operator|.
name|getState
argument_list|()
operator|.
name|equals
argument_list|(
literal|"VIC"
argument_list|)
assert|;
assert|assert
name|csvSkipField
operator|.
name|getZip
argument_list|()
operator|.
name|equals
argument_list|(
literal|"3000"
argument_list|)
assert|;
assert|assert
name|csvSkipField
operator|.
name|getCountry
argument_list|()
operator|.
name|equals
argument_list|(
literal|"Australia"
argument_list|)
assert|;
assert|assert
name|csvSkipField
operator|.
name|getDummy2
argument_list|()
operator|.
name|equals
argument_list|(
literal|"end of record"
argument_list|)
assert|;
block|}
block|}
argument_list|)
operator|.
name|marshal
argument_list|(
name|camelDataFormat
argument_list|)
operator|.
name|convertBodyTo
argument_list|(
name|String
operator|.
name|class
argument_list|)
operator|.
name|to
argument_list|(
name|URI_MOCK_RESULT
argument_list|)
expr_stmt|;
block|}
block|}
annotation|@
name|CsvRecord
argument_list|(
name|separator
operator|=
literal|","
argument_list|,
name|skipField
operator|=
literal|true
argument_list|)
DECL|class|CsvSkipField
specifier|public
specifier|static
class|class
name|CsvSkipField
block|{
annotation|@
name|DataField
argument_list|(
name|pos
operator|=
literal|1
argument_list|)
DECL|field|attention
specifier|private
name|String
name|attention
decl_stmt|;
annotation|@
name|DataField
argument_list|(
name|pos
operator|=
literal|2
argument_list|)
DECL|field|addressLine1
specifier|private
name|String
name|addressLine1
decl_stmt|;
annotation|@
name|DataField
argument_list|(
name|pos
operator|=
literal|4
argument_list|)
DECL|field|city
specifier|private
name|String
name|city
decl_stmt|;
annotation|@
name|DataField
argument_list|(
name|pos
operator|=
literal|5
argument_list|)
DECL|field|state
specifier|private
name|String
name|state
decl_stmt|;
annotation|@
name|DataField
argument_list|(
name|pos
operator|=
literal|6
argument_list|)
DECL|field|zip
specifier|private
name|String
name|zip
decl_stmt|;
annotation|@
name|DataField
argument_list|(
name|pos
operator|=
literal|7
argument_list|)
DECL|field|country
specifier|private
name|String
name|country
decl_stmt|;
annotation|@
name|DataField
argument_list|(
name|pos
operator|=
literal|9
argument_list|)
DECL|field|dummy2
specifier|private
name|String
name|dummy2
decl_stmt|;
DECL|method|getAttention ()
specifier|public
name|String
name|getAttention
parameter_list|()
block|{
return|return
name|attention
return|;
block|}
DECL|method|setAttention (String attention)
specifier|public
name|void
name|setAttention
parameter_list|(
name|String
name|attention
parameter_list|)
block|{
name|this
operator|.
name|attention
operator|=
name|attention
expr_stmt|;
block|}
DECL|method|getAddressLine1 ()
specifier|public
name|String
name|getAddressLine1
parameter_list|()
block|{
return|return
name|addressLine1
return|;
block|}
DECL|method|setAddressLine1 (String addressLine1)
specifier|public
name|void
name|setAddressLine1
parameter_list|(
name|String
name|addressLine1
parameter_list|)
block|{
name|this
operator|.
name|addressLine1
operator|=
name|addressLine1
expr_stmt|;
block|}
DECL|method|getCity ()
specifier|public
name|String
name|getCity
parameter_list|()
block|{
return|return
name|city
return|;
block|}
DECL|method|setCity (String city)
specifier|public
name|void
name|setCity
parameter_list|(
name|String
name|city
parameter_list|)
block|{
name|this
operator|.
name|city
operator|=
name|city
expr_stmt|;
block|}
DECL|method|getState ()
specifier|public
name|String
name|getState
parameter_list|()
block|{
return|return
name|state
return|;
block|}
DECL|method|setState (String state)
specifier|public
name|void
name|setState
parameter_list|(
name|String
name|state
parameter_list|)
block|{
name|this
operator|.
name|state
operator|=
name|state
expr_stmt|;
block|}
DECL|method|getZip ()
specifier|public
name|String
name|getZip
parameter_list|()
block|{
return|return
name|zip
return|;
block|}
DECL|method|setZip (String zip)
specifier|public
name|void
name|setZip
parameter_list|(
name|String
name|zip
parameter_list|)
block|{
name|this
operator|.
name|zip
operator|=
name|zip
expr_stmt|;
block|}
DECL|method|getCountry ()
specifier|public
name|String
name|getCountry
parameter_list|()
block|{
return|return
name|country
return|;
block|}
DECL|method|setCountry (String country)
specifier|public
name|void
name|setCountry
parameter_list|(
name|String
name|country
parameter_list|)
block|{
name|this
operator|.
name|country
operator|=
name|country
expr_stmt|;
block|}
DECL|method|getDummy2 ()
specifier|public
name|String
name|getDummy2
parameter_list|()
block|{
return|return
name|dummy2
return|;
block|}
DECL|method|setDummy2 (String dummy2)
specifier|public
name|void
name|setDummy2
parameter_list|(
name|String
name|dummy2
parameter_list|)
block|{
name|this
operator|.
name|dummy2
operator|=
name|dummy2
expr_stmt|;
block|}
annotation|@
name|Override
DECL|method|toString ()
specifier|public
name|String
name|toString
parameter_list|()
block|{
return|return
literal|"Record [attention="
operator|+
name|getAttention
argument_list|()
operator|+
literal|", addressLine1="
operator|+
name|getAddressLine1
argument_list|()
operator|+
literal|", "
operator|+
literal|"city="
operator|+
name|getCity
argument_list|()
operator|+
literal|", state="
operator|+
name|getState
argument_list|()
operator|+
literal|", zip="
operator|+
name|getZip
argument_list|()
operator|+
literal|", country="
operator|+
name|getCountry
argument_list|()
operator|+
literal|", dummy2="
operator|+
name|getDummy2
argument_list|()
operator|+
literal|"]"
return|;
block|}
block|}
block|}
end_class
end_unit
| begin_unit|revision:0.9.5;language:Java;cregit-version:0.0.1
VAR_0
comment|/* * 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. */
end_comment
begin_package
VAR_1|package|org.apache.camel.dataformat.bindy.CLASS_1
package|package
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|dataformat
operator|.
name|bindy
operator|.
name|CLASS_1
package|;
end_package
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|EndpointInject
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|Exchange
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|Processor
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|Produce
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|ProducerTemplate
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|builder
operator|.
name|RouteBuilder
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|component
operator|.
name|mock
operator|.
name|MockEndpoint
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|dataformat
operator|.
name|bindy
operator|.
name|VAR_2
operator|.
name|CsvRecord
import|;
end_import
begin_import
import|import
name|org
operator|.
name|apache
operator|.
name|camel
operator|.
name|dataformat
operator|.
name|bindy
operator|.
name|VAR_2
operator|.
name|DataField
import|;
end_import
begin_import
import|import
name|org
operator|.
name|junit
operator|.
name|Test
import|;
end_import
begin_import
import|import
name|org
operator|.
name|springframework
operator|.
name|test
operator|.
name|VAR_2
operator|.
name|VAR_3
import|;
end_import
begin_import
import|import
name|org
operator|.
name|springframework
operator|.
name|test
operator|.
name|context
operator|.
name|ContextConfiguration
import|;
end_import
begin_import
import|import
name|org
operator|.
name|springframework
operator|.
name|test
operator|.
name|context
operator|.
name|junit4
operator|.
name|AbstractJUnit4SpringContextTests
import|;
end_import
begin_class
VAR_2|@
name|ContextConfiguration
VAR_1|VAR_4|BindyCsvSkipFieldTest
specifier|public
VAR_4|CLASS_3
name|BindyCsvSkipFieldTest
extends|extends
name|AbstractJUnit4SpringContextTests
block|{
VAR_1|field|URI_MOCK_RESULT
specifier|private
specifier|CLASS_4
specifier|final
name|String
name|URI_MOCK_RESULT
VAR_5|=
literal|"mock:result"
decl_stmt|;
VAR_1|field|URI_DIRECT_START
specifier|private
specifier|CLASS_4
specifier|final
name|String
name|URI_DIRECT_START
VAR_5|=
literal|"direct:start"
decl_stmt|;
VAR_1|field|input
specifier|private
specifier|CLASS_4
name|String
name|input
VAR_5|=
literal|"VOA,12 abc street,Skip Street,Melbourne,VIC,3000,Australia,Skip dummy1,end of record"
decl_stmt|;
VAR_2|@
name|Produce
argument_list|(
name|URI_DIRECT_START
argument_list|)
CLASS_0|field|template
specifier|private
name|ProducerTemplate
name|template
decl_stmt|;
VAR_2|@
name|EndpointInject
argument_list|(
name|URI_MOCK_RESULT
argument_list|)
CLASS_0|field|result
specifier|private
name|MockEndpoint
name|result
decl_stmt|;
VAR_2|@
name|Test
VAR_2|@
name|VAR_3
VAR_1|VAR_6|testUnMarshalAndMarshal ()
specifier|public
name|void
name|testUnMarshalAndMarshal
parameter_list|()
throws|throws
name|CLASS_5
block|{
name|template
operator|.
name|sendBody
argument_list|(
name|input
argument_list|)
expr_stmt|;
name|result
operator|.
name|expectedMessageCount
argument_list|(
literal|1
argument_list|)
expr_stmt|;
name|result
operator|.
name|assertIsSatisfied
argument_list|()
expr_stmt|;
block|}
CLASS_0|class|ContextConfig
specifier|public
specifier|static
class|class
name|ContextConfig
extends|extends
name|RouteBuilder
block|{
CLASS_0|field|camelDataFormat
name|BindyCsvDataFormat
name|camelDataFormat
VAR_5|=
operator|new
name|BindyCsvDataFormat
argument_list|(
name|CsvSkipField
operator|.
name|class
argument_list|)
decl_stmt|;
CLASS_2|@
name|Override
VAR_1|VAR_6|configure ()
specifier|public
name|void
name|configure
parameter_list|()
block|{
name|CLASS_6
argument_list|(
name|URI_DIRECT_START
argument_list|)
operator|.
name|unmarshal
argument_list|(
name|camelDataFormat
argument_list|)
operator|.
name|process
argument_list|(
operator|new
name|Processor
argument_list|()
block|{
CLASS_2|@
name|Override
specifier|public
name|void
name|process
parameter_list|(
name|Exchange
name|exchange
parameter_list|)
throws|throws
name|CLASS_5
block|{
name|CsvSkipField
name|csvSkipField
VAR_5|=
operator|(
name|CsvSkipField
operator|)
name|exchange
operator|.
name|getIn
argument_list|()
operator|.
name|getBody
argument_list|()
decl_stmt|;
assert|assert
name|csvSkipField
operator|.
name|getAttention
argument_list|()
operator|.
name|equals
argument_list|(
literal|"VOA"
argument_list|)
assert|;
assert|assert
name|csvSkipField
operator|.
name|getAddressLine1
argument_list|()
operator|.
name|equals
argument_list|(
literal|"12 abc VAR_7"
argument_list|)
assert|;
assert|assert
name|csvSkipField
operator|.
name|getCity
argument_list|()
operator|.
name|equals
argument_list|(
literal|"VAR_8"
argument_list|)
assert|;
assert|assert
name|csvSkipField
operator|.
name|getState
argument_list|()
operator|.
name|equals
argument_list|(
literal|"VAR_9"
argument_list|)
assert|;
assert|assert
name|csvSkipField
operator|.
name|getZip
argument_list|()
operator|.
name|equals
argument_list|(
literal|"3000"
argument_list|)
assert|;
assert|assert
name|csvSkipField
operator|.
name|getCountry
argument_list|()
operator|.
name|equals
argument_list|(
literal|"Australia"
argument_list|)
assert|;
assert|assert
name|csvSkipField
operator|.
name|getDummy2
argument_list|()
operator|.
name|equals
argument_list|(
literal|"end of record"
argument_list|)
assert|;
block|}
block|}
argument_list|)
operator|.
name|marshal
argument_list|(
name|camelDataFormat
argument_list|)
operator|.
name|convertBodyTo
argument_list|(
name|String
operator|.
name|class
argument_list|)
operator|.
name|to
argument_list|(
name|URI_MOCK_RESULT
argument_list|)
expr_stmt|;
block|}
block|}
annotation|@
name|CsvRecord
argument_list|(
name|separator
operator|=
literal|","
argument_list|,
name|skipField
operator|=
literal|true
argument_list|)
DECL|class|CsvSkipField
specifier|public
specifier|static
class|class
name|CsvSkipField
block|{
annotation|@
name|DataField
argument_list|(
name|pos
operator|=
literal|1
argument_list|)
DECL|field|attention
specifier|private
name|String
name|attention
decl_stmt|;
annotation|@
name|DataField
argument_list|(
name|pos
operator|=
literal|2
argument_list|)
DECL|field|addressLine1
specifier|private
name|String
name|addressLine1
decl_stmt|;
annotation|@
name|DataField
argument_list|(
name|pos
operator|=
literal|4
argument_list|)
DECL|field|city
specifier|private
name|String
name|city
decl_stmt|;
annotation|@
name|DataField
argument_list|(
name|pos
operator|=
literal|5
argument_list|)
DECL|field|state
specifier|private
name|String
name|state
decl_stmt|;
annotation|@
name|DataField
argument_list|(
name|pos
operator|=
literal|6
argument_list|)
DECL|field|zip
specifier|private
name|String
name|zip
decl_stmt|;
annotation|@
name|DataField
argument_list|(
name|pos
operator|=
literal|7
argument_list|)
DECL|field|country
specifier|private
name|String
name|country
decl_stmt|;
annotation|@
name|DataField
argument_list|(
name|pos
operator|=
literal|9
argument_list|)
DECL|field|dummy2
specifier|private
name|String
name|dummy2
decl_stmt|;
DECL|method|getAttention ()
specifier|public
name|String
name|getAttention
parameter_list|()
block|{
return|return
name|attention
return|;
block|}
DECL|method|setAttention (String attention)
specifier|public
name|void
name|setAttention
parameter_list|(
name|String
name|attention
parameter_list|)
block|{
name|this
operator|.
name|attention
operator|=
name|attention
expr_stmt|;
block|}
DECL|method|getAddressLine1 ()
specifier|public
name|String
name|getAddressLine1
parameter_list|()
block|{
return|return
name|addressLine1
return|;
block|}
DECL|method|setAddressLine1 (String addressLine1)
specifier|public
name|void
name|setAddressLine1
parameter_list|(
name|String
name|addressLine1
parameter_list|)
block|{
name|this
operator|.
name|addressLine1
operator|=
name|addressLine1
expr_stmt|;
block|}
DECL|method|getCity ()
specifier|public
name|String
name|getCity
parameter_list|()
block|{
return|return
name|city
return|;
block|}
DECL|method|setCity (String city)
specifier|public
name|void
name|setCity
parameter_list|(
name|String
name|city
parameter_list|)
block|{
name|this
operator|.
name|city
operator|=
name|city
expr_stmt|;
block|}
DECL|method|getState ()
specifier|public
name|String
name|getState
parameter_list|()
block|{
return|return
name|state
return|;
block|}
DECL|method|setState (String state)
specifier|public
name|void
name|setState
parameter_list|(
name|String
name|state
parameter_list|)
block|{
name|this
operator|.
name|state
operator|=
name|state
expr_stmt|;
block|}
DECL|method|getZip ()
specifier|public
name|String
name|getZip
parameter_list|()
block|{
return|return
name|zip
return|;
block|}
DECL|method|setZip (String zip)
specifier|public
name|void
name|setZip
parameter_list|(
name|String
name|zip
parameter_list|)
block|{
name|this
operator|.
name|zip
operator|=
name|zip
expr_stmt|;
block|}
DECL|method|getCountry ()
specifier|public
name|String
name|getCountry
parameter_list|()
block|{
return|return
name|country
return|;
block|}
DECL|method|setCountry (String country)
specifier|public
name|void
name|setCountry
parameter_list|(
name|String
name|country
parameter_list|)
block|{
name|this
operator|.
name|country
operator|=
name|country
expr_stmt|;
block|}
DECL|method|getDummy2 ()
specifier|public
name|String
name|getDummy2
parameter_list|()
block|{
return|return
name|dummy2
return|;
block|}
DECL|method|setDummy2 (String dummy2)
specifier|public
name|void
name|setDummy2
parameter_list|(
name|String
name|dummy2
parameter_list|)
block|{
name|this
operator|.
name|dummy2
operator|=
name|dummy2
expr_stmt|;
block|}
annotation|@
name|Override
DECL|method|toString ()
specifier|public
name|String
name|toString
parameter_list|()
block|{
return|return
literal|"Record [attention="
operator|+
name|getAttention
argument_list|()
operator|+
literal|", addressLine1="
operator|+
name|getAddressLine1
argument_list|()
operator|+
literal|", "
operator|+
literal|"city="
operator|+
name|getCity
argument_list|()
operator|+
literal|", state="
operator|+
name|getState
argument_list|()
operator|+
literal|", zip="
operator|+
name|getZip
argument_list|()
operator|+
literal|", country="
operator|+
name|getCountry
argument_list|()
operator|+
literal|", dummy2="
operator|+
name|getDummy2
argument_list|()
operator|+
literal|"]"
return|;
block|}
block|}
block|}
end_class
end_unit
| 0.159192 | {'VAR_0': 'begin_comment', 'VAR_1': 'DECL', 'CLASS_0': 'DECL', 'CLASS_1': 'csv', 'VAR_2': 'annotation', 'CLASS_2': 'annotation', 'VAR_3': 'DirtiesContext', 'VAR_4': 'class', 'CLASS_3': 'class', 'CLASS_4': 'static', 'VAR_5': 'init', 'VAR_6': 'method', 'CLASS_5': 'Exception', 'CLASS_6': 'from', 'VAR_7': 'street', 'VAR_8': 'Melbourne', 'VAR_9': 'VIC'} | java | Hibrido | 38.90% |
package wiki.primo.dubbo.swagger.core.configuration;
import wiki.primo.dubbo.swagger.core.common.ExtendRequestHandlerSelectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMethod;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ResponseMessage;
import springfox.documentation.spring.web.paths.RelativePathProvider;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import javax.servlet.ServletContext;
import java.util.Collections;
import java.util.List;
import static com.google.common.collect.Lists.newArrayList;
import static springfox.documentation.spi.DocumentationType.SWAGGER_2;
/**
* SwaggerConfig
*
* @author chenhx
* @date 2019-07-13 13:56
*/
@Configuration
@EnableSwagger2
@ComponentScan(basePackages = "wiki.primo.dubbo.swagger")
public class SwaggerConfig {
@Bean
@Autowired
public Docket complete(ServletContext servletContext) {
List<ResponseMessage> responseMessageList = newArrayList();
return new Docket(SWAGGER_2)
.pathProvider(new RelativePathProvider(servletContext) {
@Override
public String getApplicationBasePath() {
return "/dubbo";
}
})
.apiInfo(apiInfo())
.select()
.apis(ExtendRequestHandlerSelectors.dubboApi())
.paths(PathSelectors.any())
.build()
.groupName("dubbo")
.produces(Collections.singleton("application/json"))
.consumes(Collections.singleton("application/json"))
.useDefaultResponseMessages(false)
.globalResponseMessage(RequestMethod.GET, responseMessageList)
.globalResponseMessage(RequestMethod.POST, responseMessageList);
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Dubbo接口文档")
.description("不断尝试,不断进步")
.version("0.0.1-dev")
.build();
}
}
| package wiki.primo.dubbo.swagger.core.configuration;
import wiki.primo.dubbo.swagger.core.common.ExtendRequestHandlerSelectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RequestMethod;
import IMPORT_0.documentation.builders.ApiInfoBuilder;
import IMPORT_0.documentation.builders.PathSelectors;
import IMPORT_0.documentation.service.ApiInfo;
import IMPORT_0.documentation.service.ResponseMessage;
import IMPORT_0.documentation.spring.web.paths.RelativePathProvider;
import IMPORT_0.documentation.spring.web.plugins.Docket;
import IMPORT_0.documentation.swagger2.annotations.EnableSwagger2;
import javax.servlet.ServletContext;
import java.util.Collections;
import java.util.List;
import static com.IMPORT_1.common.collect.Lists.newArrayList;
import static IMPORT_0.documentation.spi.DocumentationType.SWAGGER_2;
/**
* SwaggerConfig
*
* @author chenhx
* @date 2019-07-13 13:56
*/
@Configuration
@EnableSwagger2
@ComponentScan(basePackages = "wiki.primo.dubbo.swagger")
public class SwaggerConfig {
@Bean
@Autowired
public Docket complete(ServletContext servletContext) {
List<ResponseMessage> responseMessageList = newArrayList();
return new Docket(SWAGGER_2)
.FUNC_0(new RelativePathProvider(servletContext) {
@Override
public String getApplicationBasePath() {
return "/dubbo";
}
})
.apiInfo(apiInfo())
.select()
.apis(ExtendRequestHandlerSelectors.dubboApi())
.paths(PathSelectors.any())
.build()
.groupName("dubbo")
.produces(Collections.singleton("application/json"))
.FUNC_1(Collections.singleton("application/json"))
.useDefaultResponseMessages(false)
.globalResponseMessage(RequestMethod.GET, responseMessageList)
.globalResponseMessage(RequestMethod.POST, responseMessageList);
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Dubbo接口文档")
.description("不断尝试,不断进步")
.FUNC_2("0.0.1-dev")
.build();
}
}
| 0.041224 | {'IMPORT_0': 'springfox', 'IMPORT_1': 'google', 'FUNC_0': 'pathProvider', 'FUNC_1': 'consumes', 'FUNC_2': 'version'} | java | Hibrido | 63.79% |
package org.pengfei.Lesson13_Common_Data_Structure.L13_S7_Trees;
public class MyTreeNode<E> implements TreePosition<E> {
private E element;
private MyTreeNode<E> parent;
private MyTreeNode<E> left;
private MyTreeNode<E> right;
public MyTreeNode(E e, MyTreeNode<E> parent, MyTreeNode<E> left, MyTreeNode<E> right) {
this.element = e;
this.parent = parent;
this.left = left;
this.right = right;
}
@Override
public E getElement() {
return this.element;
}
@Override
public MyTreeNode<E> getParent() {
return this.parent;
}
@Override
public MyTreeNode<E> getLeft() {
return this.left;
}
@Override
public MyTreeNode<E> getRight() {
return this.right;
}
@Override
public void setElement(E e) {
this.element = e;
}
public void setParent(TreePosition<E> newParent) throws IllegalArgumentException {
if (newParent instanceof MyTreeNode) {
this.parent = (MyTreeNode<E>) newParent;
} else throw new IllegalArgumentException("The parent you provide is not a valid MyTreeNode of the tree");
}
@Override
public void setLeft(TreePosition<E> newLeft) throws IllegalArgumentException {
if (newLeft instanceof MyTreeNode) this.left = (MyTreeNode<E>) newLeft;
else throw new IllegalArgumentException("The left child you provide is not a valid MyTreeNode of the tree");
}
@Override
public void setRight(TreePosition<E> newRight) throws IllegalArgumentException {
if (newRight instanceof MyTreeNode) this.right = (MyTreeNode<E>) newRight;
else throw new IllegalArgumentException("The right child you provide is not a valid MyTreeNode of the tree");
}
}
| package org.IMPORT_0.Lesson13_Common_Data_Structure.IMPORT_1;
public class CLASS_0<E> implements TreePosition<E> {
private E element;
private CLASS_0<E> parent;
private CLASS_0<E> left;
private CLASS_0<E> right;
public CLASS_0(E VAR_0, CLASS_0<E> parent, CLASS_0<E> left, CLASS_0<E> right) {
this.element = VAR_0;
this.parent = parent;
this.left = left;
this.right = right;
}
@Override
public E FUNC_0() {
return this.element;
}
@Override
public CLASS_0<E> FUNC_1() {
return this.parent;
}
@Override
public CLASS_0<E> FUNC_2() {
return this.left;
}
@Override
public CLASS_0<E> getRight() {
return this.right;
}
@Override
public void setElement(E VAR_0) {
this.element = VAR_0;
}
public void setParent(TreePosition<E> newParent) throws CLASS_1 {
if (newParent instanceof CLASS_0) {
this.parent = (CLASS_0<E>) newParent;
} else throw new CLASS_1("The parent you provide is not a valid MyTreeNode of the tree");
}
@Override
public void FUNC_3(TreePosition<E> VAR_1) throws CLASS_1 {
if (VAR_1 instanceof CLASS_0) this.left = (CLASS_0<E>) VAR_1;
else throw new CLASS_1("The left child you provide is not a valid MyTreeNode of the tree");
}
@Override
public void setRight(TreePosition<E> newRight) throws CLASS_1 {
if (newRight instanceof CLASS_0) this.right = (CLASS_0<E>) newRight;
else throw new CLASS_1("The right child you provide is not a valid MyTreeNode of the tree");
}
}
| 0.361782 | {'IMPORT_0': 'pengfei', 'IMPORT_1': 'L13_S7_Trees', 'CLASS_0': 'MyTreeNode', 'VAR_0': 'e', 'FUNC_0': 'getElement', 'FUNC_1': 'getParent', 'FUNC_2': 'getLeft', 'CLASS_1': 'IllegalArgumentException', 'FUNC_3': 'setLeft', 'VAR_1': 'newLeft'} | java | OOP | 100.00% |
package org.gjgr.datamining.gspan;
import java.util.ArrayList;
/**
* 孩子图搜寻类,在当前边的基础上寻找可能的孩子边
*
* @author lyq
*
*/
public class SubChildTraveler {
// 当前的五元组边
ArrayList<Edge> edgeSeq;
// 当前的图
Graph graph;
// 结果数据,孩子边对所属的图id组
ArrayList<Edge> childEdge;
// 图的点id对五元组id标识的映射
int[] g2s;
// 五元组id标识对图的点id的映射
int[] s2g;
// 图中边是否被用的情况
boolean f[][];
// 最右路径,rm[id]表示的是此id节点在最右路径中的下一个节点id
int[] rm;
// 下一个五元组的id
int next;
public SubChildTraveler(ArrayList<Edge> edgeSeq, Graph graph) {
this.edgeSeq = edgeSeq;
this.graph = graph;
this.childEdge = new ArrayList<>();
}
/**
* 在图中搜索可能存在的孩子边
*
* @param next
* 新加入边的节点将设置的id
*/
public void traveler() {
this.next = edgeSeq.size() + 1;
int size = graph.nodeLabels.size();
// 做id映射的初始化操作
g2s = new int[size];
s2g = new int[size];
f = new boolean[size][size];
for (int i = 0; i < size; i++) {
g2s[i] = -1;
s2g[i] = -1;
for (int j = 0; j < size; j++) {
// 代表点id为i到id为j点此边没有被用过
f[i][j] = false;
}
}
rm = new int[edgeSeq.size()+1];
for (int i = 0; i < edgeSeq.size()+1; i++) {
rm[i] = -1;
}
// 寻找最右路径
for (Edge e : edgeSeq) {
if (e.ix < e.iy && e.iy > rm[e.ix]) {
rm[e.ix] = e.iy;
}
}
for (int i = 0; i < size; i++) {
// 寻找第一个标号相等的点
if (edgeSeq.get(0).x != graph.nodeLabels.get(i)) {
continue;
}
g2s[i] = 0;
s2g[0] = i;
dfsSearchEdge(0);
g2s[i] = -1;
s2g[0] = -1;
}
}
/**
* 在当前图中深度优先寻找正确的子图
*
* @param currentPosition
* 当前找到的位置
*/
public void dfsSearchEdge(int currentPosition) {
int rmPosition = 0;
// 如果找到底了,则在当前的子图的最右路径中寻找可能的边
if (currentPosition >= edgeSeq.size()) {
rmPosition = 0;
while (rmPosition >= 0) {
int gId = s2g[rmPosition];
// 在此点附近寻找可能的边
for (int i = 0; i < graph.edgeNexts.get(gId).size(); i++) {
int gId2 = graph.edgeNexts.get(gId).get(i);
// 如果这条边已经被用过
if (f[gId][gId2] || f[gId][gId2]) {
continue;
}
// 在最右路径中添加边分为2种情况,第一种为在最右节点上添加,第二中为在最右路径上 的点添加
// 如果找到的点没有被用过,可以进行边的拓展
if (g2s[gId2] < 0) {
g2s[gId2] = next;
Edge e = new Edge(g2s[gId], g2s[gId2],
graph.nodeLabels.get(gId), graph.edgeLabels
.get(gId).get(i),
graph.nodeLabels.get(gId2));
// 将新建的子边加入集合
childEdge.add(e);
} else {
boolean flag = true;
// 如果这点已经存在,判断他是不是最右的点
for (int j = 0; j < graph.edgeNexts.get(gId2).size(); j++) {
int tempId = graph.edgeNexts.get(gId2).get(j);
if (g2s[gId2] < g2s[tempId]) {
flag = false;
break;
}
}
if (flag) {
Edge e = new Edge(g2s[gId], g2s[gId2],
graph.nodeLabels.get(gId), graph.edgeLabels
.get(gId).get(i),
graph.nodeLabels.get(gId2));
// 将新建的子边加入集合
childEdge.add(e);
}
}
}
// 一个最右路径上点找完,继续下一个
rmPosition = rm[rmPosition];
}
return;
}
Edge e = edgeSeq.get(currentPosition);
// 所连接的点标号
int y = e.y;
// 所连接的边标号
int a = e.a;
int gId1 = s2g[e.ix];
int gId2 = 0;
for (int i = 0; i < graph.edgeLabels.get(gId1).size(); i++) {
// 判断所连接的边对应的标号
if (graph.edgeLabels.get(gId1).get(i) != a) {
continue;
}
// 判断所连接的点的标号
int tempId = graph.edgeNexts.get(gId1).get(i);
if (graph.nodeLabels.get(tempId) != y) {
continue;
}
gId2 = tempId;
// 如果这两点是没有设置过的
if (g2s[gId2] == -1 && s2g[e.iy] == -1) {
g2s[gId2] = e.iy;
s2g[e.iy] = gId2;
f[gId1][gId2] = true;
f[gId2][gId1] = true;
dfsSearchEdge(currentPosition + 1);
f[gId1][gId2] = false;
f[gId2][gId1] = false;
g2s[gId2] = -1;
s2g[e.iy] = -1;
} else {
if (g2s[gId2] != e.iy) {
continue;
}
if (s2g[e.iy] != gId2) {
continue;
}
f[gId1][gId2] = true;
f[gId2][gId1] = true;
dfsSearchEdge(currentPosition);
f[gId1][gId2] = false;
f[gId2][gId1] = false;
}
}
}
/**
* 获取结果数据对
*
* @return
*/
public ArrayList<Edge> getResultChildEdge() {
return this.childEdge;
}
}
| package IMPORT_0.gjgr.IMPORT_1.gspan;
import java.IMPORT_2.ArrayList;
/**
* 孩子图搜寻类,在当前边的基础上寻找可能的孩子边
*
* @author lyq
*
*/
public class SubChildTraveler {
// 当前的五元组边
ArrayList<CLASS_0> VAR_0;
// 当前的图
CLASS_1 graph;
// 结果数据,孩子边对所属的图id组
ArrayList<CLASS_0> childEdge;
// 图的点id对五元组id标识的映射
int[] VAR_1;
// 五元组id标识对图的点id的映射
int[] s2g;
// 图中边是否被用的情况
boolean f[][];
// 最右路径,rm[id]表示的是此id节点在最右路径中的下一个节点id
int[] rm;
// 下一个五元组的id
int VAR_2;
public SubChildTraveler(ArrayList<CLASS_0> VAR_0, CLASS_1 graph) {
this.VAR_0 = VAR_0;
this.graph = graph;
this.childEdge = new ArrayList<>();
}
/**
* 在图中搜索可能存在的孩子边
*
* @param next
* 新加入边的节点将设置的id
*/
public void traveler() {
this.VAR_2 = VAR_0.size() + 1;
int size = graph.nodeLabels.size();
// 做id映射的初始化操作
VAR_1 = new int[size];
s2g = new int[size];
f = new boolean[size][size];
for (int i = 0; i < size; i++) {
VAR_1[i] = -1;
s2g[i] = -1;
for (int VAR_3 = 0; VAR_3 < size; VAR_3++) {
// 代表点id为i到id为j点此边没有被用过
f[i][VAR_3] = false;
}
}
rm = new int[VAR_0.size()+1];
for (int i = 0; i < VAR_0.size()+1; i++) {
rm[i] = -1;
}
// 寻找最右路径
for (CLASS_0 VAR_4 : VAR_0) {
if (VAR_4.VAR_5 < VAR_4.iy && VAR_4.iy > rm[VAR_4.VAR_5]) {
rm[VAR_4.VAR_5] = VAR_4.iy;
}
}
for (int i = 0; i < size; i++) {
// 寻找第一个标号相等的点
if (VAR_0.get(0).VAR_6 != graph.nodeLabels.get(i)) {
continue;
}
VAR_1[i] = 0;
s2g[0] = i;
dfsSearchEdge(0);
VAR_1[i] = -1;
s2g[0] = -1;
}
}
/**
* 在当前图中深度优先寻找正确的子图
*
* @param currentPosition
* 当前找到的位置
*/
public void dfsSearchEdge(int currentPosition) {
int rmPosition = 0;
// 如果找到底了,则在当前的子图的最右路径中寻找可能的边
if (currentPosition >= VAR_0.size()) {
rmPosition = 0;
while (rmPosition >= 0) {
int gId = s2g[rmPosition];
// 在此点附近寻找可能的边
for (int i = 0; i < graph.VAR_7.get(gId).size(); i++) {
int gId2 = graph.VAR_7.get(gId).get(i);
// 如果这条边已经被用过
if (f[gId][gId2] || f[gId][gId2]) {
continue;
}
// 在最右路径中添加边分为2种情况,第一种为在最右节点上添加,第二中为在最右路径上 的点添加
// 如果找到的点没有被用过,可以进行边的拓展
if (VAR_1[gId2] < 0) {
VAR_1[gId2] = VAR_2;
CLASS_0 VAR_4 = new CLASS_0(VAR_1[gId], VAR_1[gId2],
graph.nodeLabels.get(gId), graph.edgeLabels
.get(gId).get(i),
graph.nodeLabels.get(gId2));
// 将新建的子边加入集合
childEdge.FUNC_0(VAR_4);
} else {
boolean VAR_8 = true;
// 如果这点已经存在,判断他是不是最右的点
for (int VAR_3 = 0; VAR_3 < graph.VAR_7.get(gId2).size(); VAR_3++) {
int tempId = graph.VAR_7.get(gId2).get(VAR_3);
if (VAR_1[gId2] < VAR_1[tempId]) {
VAR_8 = false;
break;
}
}
if (VAR_8) {
CLASS_0 VAR_4 = new CLASS_0(VAR_1[gId], VAR_1[gId2],
graph.nodeLabels.get(gId), graph.edgeLabels
.get(gId).get(i),
graph.nodeLabels.get(gId2));
// 将新建的子边加入集合
childEdge.FUNC_0(VAR_4);
}
}
}
// 一个最右路径上点找完,继续下一个
rmPosition = rm[rmPosition];
}
return;
}
CLASS_0 VAR_4 = VAR_0.get(currentPosition);
// 所连接的点标号
int y = VAR_4.y;
// 所连接的边标号
int VAR_9 = VAR_4.VAR_9;
int gId1 = s2g[VAR_4.VAR_5];
int gId2 = 0;
for (int i = 0; i < graph.edgeLabels.get(gId1).size(); i++) {
// 判断所连接的边对应的标号
if (graph.edgeLabels.get(gId1).get(i) != VAR_9) {
continue;
}
// 判断所连接的点的标号
int tempId = graph.VAR_7.get(gId1).get(i);
if (graph.nodeLabels.get(tempId) != y) {
continue;
}
gId2 = tempId;
// 如果这两点是没有设置过的
if (VAR_1[gId2] == -1 && s2g[VAR_4.iy] == -1) {
VAR_1[gId2] = VAR_4.iy;
s2g[VAR_4.iy] = gId2;
f[gId1][gId2] = true;
f[gId2][gId1] = true;
dfsSearchEdge(currentPosition + 1);
f[gId1][gId2] = false;
f[gId2][gId1] = false;
VAR_1[gId2] = -1;
s2g[VAR_4.iy] = -1;
} else {
if (VAR_1[gId2] != VAR_4.iy) {
continue;
}
if (s2g[VAR_4.iy] != gId2) {
continue;
}
f[gId1][gId2] = true;
f[gId2][gId1] = true;
dfsSearchEdge(currentPosition);
f[gId1][gId2] = false;
f[gId2][gId1] = false;
}
}
}
/**
* 获取结果数据对
*
* @return
*/
public ArrayList<CLASS_0> FUNC_1() {
return this.childEdge;
}
}
| 0.340922 | {'IMPORT_0': 'org', 'IMPORT_1': 'datamining', 'IMPORT_2': 'util', 'CLASS_0': 'Edge', 'VAR_0': 'edgeSeq', 'CLASS_1': 'Graph', 'VAR_1': 'g2s', 'VAR_2': 'next', 'VAR_3': 'j', 'VAR_4': 'e', 'VAR_5': 'ix', 'VAR_6': 'x', 'VAR_7': 'edgeNexts', 'FUNC_0': 'add', 'VAR_8': 'flag', 'VAR_9': 'a', 'FUNC_1': 'getResultChildEdge'} | java | OOP | 23.95% |
/**
* Symganizer class.
* =================
*
* Contains the application logic.
*
* @author Manulaiko <[email protected]>
*/
public class Symganizer
{
/**
* Library to use.
*/
private File _library;
/**
* Constructor.
*
* @param library Library to use.
*/
public Symganizer(File library)
{
this._library = library;
}
/**
* Starts the logic for the given library.
*/
public void start()
{
Console.println("I'm going to create the directories where the symlinks will be stored.");
ContainerCreator containerCreator = new ContainerCreator();
Map<String, File> containers = containerCreator.start();
Console.println("Now I'm going to scan the library to get a list of the files/directories of it.");
LibraryScanner scanner = new LibraryScanner();
List<File> entries = scanner.scan(this._library);
entries.forEach((f)->{
EntryProcessor processor = new EntryProcessor(f, containers);
processor.process();
});
Console.println("Finished processing library `"+ this._library.getAbsolutePath() +"`!");
}
} | /**
* Symganizer class.
* =================
*
* Contains the application logic.
*
* @author Manulaiko <[email protected]>
*/
public class Symganizer
{
/**
* Library to use.
*/
private File VAR_0;
/**
* Constructor.
*
* @param library Library to use.
*/
public Symganizer(File library)
{
this.VAR_0 = library;
}
/**
* Starts the logic for the given library.
*/
public void start()
{
VAR_1.FUNC_0("I'm going to create the directories where the symlinks will be stored.");
CLASS_0 containerCreator = new CLASS_0();
CLASS_1<CLASS_2, File> containers = containerCreator.start();
VAR_1.FUNC_0("Now I'm going to scan the library to get a list of the files/directories of it.");
CLASS_3 VAR_2 = new CLASS_3();
List<File> VAR_3 = VAR_2.FUNC_1(this.VAR_0);
VAR_3.FUNC_2((VAR_4)->{
CLASS_4 VAR_5 = new CLASS_4(VAR_4, containers);
VAR_5.process();
});
VAR_1.FUNC_0("Finished processing library `"+ this.VAR_0.getAbsolutePath() +"`!");
}
} | 0.664312 | {'VAR_0': '_library', 'VAR_1': 'Console', 'FUNC_0': 'println', 'CLASS_0': 'ContainerCreator', 'CLASS_1': 'Map', 'CLASS_2': 'String', 'CLASS_3': 'LibraryScanner', 'VAR_2': 'scanner', 'VAR_3': 'entries', 'FUNC_1': 'scan', 'FUNC_2': 'forEach', 'VAR_4': 'f', 'CLASS_4': 'EntryProcessor', 'VAR_5': 'processor'} | java | OOP | 82.14% |
package getServletContext;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class servlet3 extends HttpServlet {
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
{
PrintWriter pw=res.getWriter();
Cookie ck[]=req.getCookies();
String per=req.getParameter("perc");
String qual=req.getParameter("qual");
pw.println(per);
pw.println(qual);
pw.println(ck[0].getValue());
pw.println(ck[1].getValue());
pw.println(ck[2].getValue());
pw.println(ck[3].getValue());
pw.println(ck[4].getValue());
pw.println(ck[5].getValue());
}
}
| package getServletContext;
import IMPORT_0.io.IOException;
import IMPORT_0.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.IMPORT_1;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.IMPORT_2;
import javax.servlet.http.HttpSession;
public class servlet3 extends HttpServlet {
protected void doGet(HttpServletRequest req, IMPORT_2 res) throws ServletException, IOException
{
PrintWriter pw=res.getWriter();
IMPORT_1 VAR_0[]=req.getCookies();
String VAR_1=req.getParameter("perc");
String qual=req.getParameter("qual");
pw.println(VAR_1);
pw.println(qual);
pw.println(VAR_0[0].getValue());
pw.println(VAR_0[1].getValue());
pw.println(VAR_0[2].getValue());
pw.println(VAR_0[3].getValue());
pw.println(VAR_0[4].getValue());
pw.println(VAR_0[5].getValue());
}
}
| 0.153219 | {'IMPORT_0': 'java', 'IMPORT_1': 'Cookie', 'IMPORT_2': 'HttpServletResponse', 'VAR_0': 'ck', 'VAR_1': 'per'} | java | OOP | 70.07% |
package com.github.shootercheng.export.core;
import com.github.shootercheng.common.constant.CommonConstants;
import com.github.shootercheng.common.util.DataUtil;
import com.github.shootercheng.export.common.ExportCommon;
import com.github.shootercheng.export.exception.ExportException;
import com.github.shootercheng.export.param.ExportParam;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
/**
* @author James
*/
public interface DataListExport extends BaseExport {
default <T> void exportList(List<T> dataList, ExportParam exportParam) {
List<Method> getterMethods = exportParam.getGetterMethod();
for (Object object : dataList) {
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < getterMethods.size(); i++) {
try {
Method method = getterMethods.get(i);
Object value = method.invoke(object, CommonConstants.NO_ARGUMENTS);
if (value != null) {
String columnChar = DataUtil.COLUMN_NUM.get(i);
if (exportParam.getCellFormat() != null) {
value = exportParam.getCellFormat().format(columnChar, String.valueOf(value));
}
stringBuilder.append("\"").append(value).append("\"").append(",");
} else {
stringBuilder.append("\"").append("\"").append(",");
}
} catch (IllegalAccessException e) {
throw new ExportException("illegal access exception", e);
} catch (InvocationTargetException e) {
throw new ExportException("invocation target exception", e);
}
}
String rowData = stringBuilder.toString();
if (rowData.length() > 1) {
rowData = rowData.substring(0, rowData.length() - 1);
}
processRowData(rowData);
}
}
}
| package com.github.shootercheng.export.IMPORT_0;
import com.github.shootercheng.common.IMPORT_1.IMPORT_2;
import com.github.shootercheng.common.IMPORT_3.IMPORT_4;
import com.github.shootercheng.export.common.IMPORT_5;
import com.github.shootercheng.export.IMPORT_6.IMPORT_7;
import com.github.shootercheng.export.param.ExportParam;
import IMPORT_8.IMPORT_9.reflect.InvocationTargetException;
import IMPORT_8.IMPORT_9.reflect.IMPORT_10;
import IMPORT_8.IMPORT_3.List;
/**
* @author James
*/
public interface CLASS_0 extends CLASS_1 {
default <CLASS_2> void FUNC_0(List<CLASS_2> VAR_0, ExportParam exportParam) {
List<IMPORT_10> getterMethods = exportParam.getGetterMethod();
for (Object object : VAR_0) {
CLASS_3 stringBuilder = new CLASS_3();
for (int i = 0; i < getterMethods.size(); i++) {
try {
IMPORT_10 VAR_1 = getterMethods.get(i);
Object value = VAR_1.invoke(object, IMPORT_2.VAR_2);
if (value != null) {
CLASS_4 columnChar = IMPORT_4.VAR_4.get(i);
if (exportParam.getCellFormat() != null) {
value = exportParam.getCellFormat().FUNC_1(columnChar, VAR_3.FUNC_2(value));
}
stringBuilder.append("\"").append(value).append("\"").append(",");
} else {
stringBuilder.append("\"").append("\"").append(",");
}
} catch (IllegalAccessException e) {
throw new IMPORT_7("illegal access exception", e);
} catch (InvocationTargetException e) {
throw new IMPORT_7("invocation target exception", e);
}
}
CLASS_4 rowData = stringBuilder.toString();
if (rowData.FUNC_3() > 1) {
rowData = rowData.FUNC_4(0, rowData.FUNC_3() - 1);
}
FUNC_5(rowData);
}
}
}
| 0.335701 | {'IMPORT_0': 'core', 'IMPORT_1': 'constant', 'IMPORT_2': 'CommonConstants', 'IMPORT_3': 'util', 'IMPORT_4': 'DataUtil', 'IMPORT_5': 'ExportCommon', 'IMPORT_6': 'exception', 'IMPORT_7': 'ExportException', 'IMPORT_8': 'java', 'IMPORT_9': 'lang', 'IMPORT_10': 'Method', 'CLASS_0': 'DataListExport', 'CLASS_1': 'BaseExport', 'CLASS_2': 'T', 'FUNC_0': 'exportList', 'VAR_0': 'dataList', 'CLASS_3': 'StringBuilder', 'VAR_1': 'method', 'VAR_2': 'NO_ARGUMENTS', 'CLASS_4': 'String', 'VAR_3': 'String', 'VAR_4': 'COLUMN_NUM', 'FUNC_1': 'format', 'FUNC_2': 'valueOf', 'FUNC_3': 'length', 'FUNC_4': 'substring', 'FUNC_5': 'processRowData'} | java | Texto | 26.25% |
/*******************************************************************************
**NOTE** This code was generated by a tool and will occasionally be
overwritten. We welcome comments and issues regarding this code; they will be
addressed in the generation tool. If you wish to submit pull requests, please
do so for the templates in that tool.
This code was generated by Vipr (https://github.com/microsoft/vipr) using
the T4TemplateWriter (https://github.com/msopentech/vipr-t4templatewriter).
Copyright (c) Microsoft Corporation. All Rights Reserved.
Licensed under the Apache License 2.0; see LICENSE in the source repository
root for authoritative license information.
******************************************************************************/
package com.microsoft.services.outlook;
import com.microsoft.services.orc.core.ODataBaseEntity;
/**
* The type Geo Coordinates.
*/
public class GeoCoordinates extends ODataBaseEntity {
public GeoCoordinates(){
setODataType("#Microsoft.OutlookServices.GeoCoordinates");
}
private Double Altitude;
/**
* Gets the Altitude.
*
* @return the Double
*/
public Double getAltitude() {
return this.Altitude;
}
/**
* Sets the Altitude.
*
* @param value the Double
*/
public void setAltitude(Double value) {
this.Altitude = value;
valueChanged("Altitude", value);
}
private Double Latitude;
/**
* Gets the Latitude.
*
* @return the Double
*/
public Double getLatitude() {
return this.Latitude;
}
/**
* Sets the Latitude.
*
* @param value the Double
*/
public void setLatitude(Double value) {
this.Latitude = value;
valueChanged("Latitude", value);
}
private Double Longitude;
/**
* Gets the Longitude.
*
* @return the Double
*/
public Double getLongitude() {
return this.Longitude;
}
/**
* Sets the Longitude.
*
* @param value the Double
*/
public void setLongitude(Double value) {
this.Longitude = value;
valueChanged("Longitude", value);
}
private Double Accuracy;
/**
* Gets the Accuracy.
*
* @return the Double
*/
public Double getAccuracy() {
return this.Accuracy;
}
/**
* Sets the Accuracy.
*
* @param value the Double
*/
public void setAccuracy(Double value) {
this.Accuracy = value;
valueChanged("Accuracy", value);
}
private Double AltitudeAccuracy;
/**
* Gets the Altitude Accuracy.
*
* @return the Double
*/
public Double getAltitudeAccuracy() {
return this.AltitudeAccuracy;
}
/**
* Sets the Altitude Accuracy.
*
* @param value the Double
*/
public void setAltitudeAccuracy(Double value) {
this.AltitudeAccuracy = value;
valueChanged("AltitudeAccuracy", value);
}
}
| /*******************************************************************************
**NOTE** This code was generated by a tool and will occasionally be
overwritten. We welcome comments and issues regarding this code; they will be
addressed in the generation tool. If you wish to submit pull requests, please
do so for the templates in that tool.
This code was generated by Vipr (https://github.com/microsoft/vipr) using
the T4TemplateWriter (https://github.com/msopentech/vipr-t4templatewriter).
Copyright (c) Microsoft Corporation. All Rights Reserved.
Licensed under the Apache License 2.0; see LICENSE in the source repository
root for authoritative license information.
******************************************************************************/
package IMPORT_0.microsoft.services.IMPORT_1;
import IMPORT_0.microsoft.services.IMPORT_2.IMPORT_3.ODataBaseEntity;
/**
* The type Geo Coordinates.
*/
public class CLASS_0 extends ODataBaseEntity {
public CLASS_0(){
FUNC_0("#Microsoft.OutlookServices.GeoCoordinates");
}
private CLASS_1 VAR_0;
/**
* Gets the Altitude.
*
* @return the Double
*/
public CLASS_1 getAltitude() {
return this.VAR_0;
}
/**
* Sets the Altitude.
*
* @param value the Double
*/
public void FUNC_1(CLASS_1 value) {
this.VAR_0 = value;
valueChanged("Altitude", value);
}
private CLASS_1 VAR_1;
/**
* Gets the Latitude.
*
* @return the Double
*/
public CLASS_1 FUNC_2() {
return this.VAR_1;
}
/**
* Sets the Latitude.
*
* @param value the Double
*/
public void FUNC_3(CLASS_1 value) {
this.VAR_1 = value;
valueChanged("Latitude", value);
}
private CLASS_1 VAR_2;
/**
* Gets the Longitude.
*
* @return the Double
*/
public CLASS_1 getLongitude() {
return this.VAR_2;
}
/**
* Sets the Longitude.
*
* @param value the Double
*/
public void FUNC_4(CLASS_1 value) {
this.VAR_2 = value;
valueChanged("Longitude", value);
}
private CLASS_1 Accuracy;
/**
* Gets the Accuracy.
*
* @return the Double
*/
public CLASS_1 FUNC_5() {
return this.Accuracy;
}
/**
* Sets the Accuracy.
*
* @param value the Double
*/
public void FUNC_6(CLASS_1 value) {
this.Accuracy = value;
valueChanged("Accuracy", value);
}
private CLASS_1 VAR_3;
/**
* Gets the Altitude Accuracy.
*
* @return the Double
*/
public CLASS_1 getAltitudeAccuracy() {
return this.VAR_3;
}
/**
* Sets the Altitude Accuracy.
*
* @param value the Double
*/
public void FUNC_7(CLASS_1 value) {
this.VAR_3 = value;
valueChanged("AltitudeAccuracy", value);
}
}
| 0.612248 | {'IMPORT_0': 'com', 'IMPORT_1': 'outlook', 'IMPORT_2': 'orc', 'IMPORT_3': 'core', 'CLASS_0': 'GeoCoordinates', 'FUNC_0': 'setODataType', 'CLASS_1': 'Double', 'VAR_0': 'Altitude', 'FUNC_1': 'setAltitude', 'VAR_1': 'Latitude', 'FUNC_2': 'getLatitude', 'FUNC_3': 'setLatitude', 'VAR_2': 'Longitude', 'FUNC_4': 'setLongitude', 'FUNC_5': 'getAccuracy', 'FUNC_6': 'setAccuracy', 'VAR_3': 'AltitudeAccuracy', 'FUNC_7': 'setAltitudeAccuracy'} | java | Hibrido | 100.00% |
package com.milelu.service.mapper;
import java.util.List;
import com.milelu.common.utils.model.KeyValueModel;
import com.milelu.service.domain.Model;
/**
* 模型Mapper接口
*
* @author MILELU
* @date 2021-01-21
*/
public interface ModelMapper
{
/**
* 查询模型
*
* @param id 模型ID
* @return 模型
*/
public Model selectModelById(String id);
/**
* 查询模型列表
*
* @param model 模型
* @return 模型集合
*/
public List<Model> selectModelList(Model model);
/**
* 新增模型
*
* @param model 模型
* @return 结果
*/
public int insertModel(Model model);
/**
* 修改模型
*
* @param model 模型
* @return 结果
*/
public int updateModel(Model model);
/**
* 删除模型
*
* @param id 模型ID
* @return 结果
*/
public int deleteModelById(String id);
/**
* 批量删除模型
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteModelByIds(String[] ids);
/**
* 根据分类id查询
* @param categoryId
* @return
*/
List<Model> listModelByCategoryId(String categoryId);
List<KeyValueModel> listPublishModel(String categoryId);
}
| package IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3;
import java.util.List;
import IMPORT_0.IMPORT_1.IMPORT_4.IMPORT_5.model.IMPORT_6;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_7.IMPORT_8;
/**
* 模型Mapper接口
*
* @author MILELU
* @date 2021-01-21
*/
public interface ModelMapper
{
/**
* 查询模型
*
* @param id 模型ID
* @return 模型
*/
public IMPORT_8 FUNC_0(CLASS_0 VAR_0);
/**
* 查询模型列表
*
* @param model 模型
* @return 模型集合
*/
public List<IMPORT_8> FUNC_1(IMPORT_8 model);
/**
* 新增模型
*
* @param model 模型
* @return 结果
*/
public int FUNC_2(IMPORT_8 model);
/**
* 修改模型
*
* @param model 模型
* @return 结果
*/
public int FUNC_3(IMPORT_8 model);
/**
* 删除模型
*
* @param id 模型ID
* @return 结果
*/
public int FUNC_4(CLASS_0 VAR_0);
/**
* 批量删除模型
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int FUNC_5(CLASS_0[] VAR_1);
/**
* 根据分类id查询
* @param categoryId
* @return
*/
List<IMPORT_8> FUNC_6(CLASS_0 VAR_2);
List<IMPORT_6> FUNC_7(CLASS_0 VAR_2);
}
| 0.785412 | {'IMPORT_0': 'com', 'IMPORT_1': 'milelu', 'IMPORT_2': 'service', 'IMPORT_3': 'mapper', 'IMPORT_4': 'common', 'IMPORT_5': 'utils', 'IMPORT_6': 'KeyValueModel', 'IMPORT_7': 'domain', 'IMPORT_8': 'Model', 'FUNC_0': 'selectModelById', 'CLASS_0': 'String', 'VAR_0': 'id', 'FUNC_1': 'selectModelList', 'FUNC_2': 'insertModel', 'FUNC_3': 'updateModel', 'FUNC_4': 'deleteModelById', 'FUNC_5': 'deleteModelByIds', 'VAR_1': 'ids', 'FUNC_6': 'listModelByCategoryId', 'VAR_2': 'categoryId', 'FUNC_7': 'listPublishModel'} | java | Texto | 26.55% |
package log;
import java.io.Console;
public class IGLog {
private static final Console CONSOLE = System.console();
private static final String YELLOW = "\033[1;33m";
private static final String RED = "\033[0;31m";
private static final String CLEAR = "\033[0m";
private static String addColors(String color, String message) {
String useColor;
String useClear;
if (CONSOLE == null) {
useColor = "";
useClear = "";
} else {
useColor = color;
useClear = CLEAR;
}
return useColor + message + useClear;
}
public static void write(String message) {
System.out.println(message);
}
public static void info(String message) {
System.out.println(addColors(YELLOW, message));
}
public static void error(String message) {
System.err.println(addColors(RED, message));
}
}
| package VAR_0;
import IMPORT_0.io.Console;
public class CLASS_0 {
private static final Console VAR_1 = System.console();
private static final String VAR_2 = "\033[1;33m";
private static final String VAR_3 = "\033[0;31m";
private static final String VAR_4 = "\033[0m";
private static String FUNC_0(String VAR_5, String VAR_6) {
String useColor;
String VAR_7;
if (VAR_1 == null) {
useColor = "";
VAR_7 = "";
} else {
useColor = VAR_5;
VAR_7 = VAR_4;
}
return useColor + VAR_6 + VAR_7;
}
public static void FUNC_1(String VAR_6) {
System.out.println(VAR_6);
}
public static void FUNC_2(String VAR_6) {
System.out.println(FUNC_0(VAR_2, VAR_6));
}
public static void FUNC_3(String VAR_6) {
System.VAR_8.println(FUNC_0(VAR_3, VAR_6));
}
}
| 0.662212 | {'VAR_0': 'log', 'IMPORT_0': 'java', 'CLASS_0': 'IGLog', 'VAR_1': 'CONSOLE', 'VAR_2': 'YELLOW', 'VAR_3': 'RED', 'VAR_4': 'CLEAR', 'FUNC_0': 'addColors', 'VAR_5': 'color', 'VAR_6': 'message', 'VAR_7': 'useClear', 'FUNC_1': 'write', 'FUNC_2': 'info', 'FUNC_3': 'error', 'VAR_8': 'err'} | java | OOP | 79.53% |
package com.humane.application.views.database;
import com.vaadin.flow.component.dependency.CssImport;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.data.value.ValueChangeMode;
import com.vaadin.flow.router.PageTitle;
import com.vaadin.flow.router.Route;
import com.vaadin.flow.component.grid.Grid;
import com.humane.application.views.main.MainView;
import com.vaadin.flow.router.RouteAlias;
import com.humane.application.AnimalService;
import com.humane.application.Animal;
import com.humane.application.AnimalForm;
@Route(value = "hello", layout = MainView.class)
@PageTitle("Database")
@CssImport("./styles/views/database/database-view.css")
@RouteAlias(value = "", layout = MainView.class)
public class DatabaseView extends VerticalLayout {
/**
*
*/
private static final long serialVersionUID = 1L;
private AnimalService service = AnimalService.getInstance();
private Grid<Animal> grid = new Grid<>(Animal.class);
private TextField filterText = new TextField();
private AnimalForm form = new AnimalForm(this);
public DatabaseView() {
setId("database-view");
grid.setColumns("name", "status");
add(filterText, grid, form);
filterText.setPlaceholder("Filter by name...");
filterText.setClearButtonVisible(true);
filterText.setValueChangeMode(ValueChangeMode.EAGER);
filterText.addValueChangeListener(e -> updateList());
updateList();
form.setAnimal(null);
grid.asSingleSelect().addValueChangeListener(event ->
form.setAnimal(grid.asSingleSelect().getValue()));
}
public void updateList() {
grid.setItems(service.findAll(filterText.getValue()));
}
}
| package IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3.IMPORT_4;
import IMPORT_0.IMPORT_5.IMPORT_6.IMPORT_7.IMPORT_8.IMPORT_9;
import IMPORT_0.IMPORT_5.IMPORT_6.IMPORT_7.IMPORT_10.IMPORT_11;
import IMPORT_0.IMPORT_5.IMPORT_6.IMPORT_7.IMPORT_12.IMPORT_13;
import IMPORT_0.IMPORT_5.IMPORT_6.IMPORT_14.IMPORT_15.IMPORT_16;
import IMPORT_0.IMPORT_5.IMPORT_6.IMPORT_17.IMPORT_18;
import IMPORT_0.IMPORT_5.IMPORT_6.IMPORT_17.IMPORT_19;
import IMPORT_0.IMPORT_5.IMPORT_6.IMPORT_7.IMPORT_20.IMPORT_21;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3.IMPORT_22.IMPORT_23;
import IMPORT_0.IMPORT_5.IMPORT_6.IMPORT_17.IMPORT_24;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_25;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_26;
import IMPORT_0.IMPORT_1.IMPORT_2.AnimalForm;
@IMPORT_19(IMPORT_15 = "hello", VAR_0 = IMPORT_23.class)
@IMPORT_18("Database")
@IMPORT_9("./styles/views/database/database-view.css")
@IMPORT_24(IMPORT_15 = "", VAR_0 = IMPORT_23.class)
public class CLASS_0 extends IMPORT_11 {
/**
*
*/
private static final long VAR_1 = 1L;
private IMPORT_25 VAR_2 = IMPORT_25.FUNC_0();
private IMPORT_21<IMPORT_26> IMPORT_20 = new IMPORT_21<>(IMPORT_26.class);
private IMPORT_13 VAR_3 = new IMPORT_13();
private AnimalForm VAR_4 = new AnimalForm(this);
public CLASS_0() {
FUNC_1("database-view");
IMPORT_20.FUNC_2("name", "status");
FUNC_3(VAR_3, IMPORT_20, VAR_4);
VAR_3.FUNC_4("Filter by name...");
VAR_3.FUNC_5(true);
VAR_3.FUNC_6(IMPORT_16.VAR_5);
VAR_3.FUNC_7(VAR_6 -> FUNC_8());
FUNC_8();
VAR_4.FUNC_9(null);
IMPORT_20.FUNC_10().FUNC_7(VAR_7 ->
VAR_4.FUNC_9(IMPORT_20.FUNC_10().FUNC_11()));
}
public void FUNC_8() {
IMPORT_20.FUNC_12(VAR_2.FUNC_13(VAR_3.FUNC_11()));
}
}
| 0.95085 | {'IMPORT_0': 'com', 'IMPORT_1': 'humane', 'IMPORT_2': 'application', 'IMPORT_3': 'views', 'IMPORT_4': 'database', 'IMPORT_5': 'vaadin', 'IMPORT_6': 'flow', 'IMPORT_7': 'component', 'IMPORT_8': 'dependency', 'IMPORT_9': 'CssImport', 'IMPORT_10': 'orderedlayout', 'IMPORT_11': 'VerticalLayout', 'IMPORT_12': 'textfield', 'IMPORT_13': 'TextField', 'IMPORT_14': 'data', 'IMPORT_15': 'value', 'IMPORT_16': 'ValueChangeMode', 'IMPORT_17': 'router', 'IMPORT_18': 'PageTitle', 'IMPORT_19': 'Route', 'IMPORT_20': 'grid', 'IMPORT_21': 'Grid', 'IMPORT_22': 'main', 'IMPORT_23': 'MainView', 'IMPORT_24': 'RouteAlias', 'IMPORT_25': 'AnimalService', 'IMPORT_26': 'Animal', 'VAR_0': 'layout', 'CLASS_0': 'DatabaseView', 'VAR_1': 'serialVersionUID', 'VAR_2': 'service', 'FUNC_0': 'getInstance', 'VAR_3': 'filterText', 'VAR_4': 'form', 'FUNC_1': 'setId', 'FUNC_2': 'setColumns', 'FUNC_3': 'add', 'FUNC_4': 'setPlaceholder', 'FUNC_5': 'setClearButtonVisible', 'FUNC_6': 'setValueChangeMode', 'VAR_5': 'EAGER', 'FUNC_7': 'addValueChangeListener', 'VAR_6': 'e', 'FUNC_8': 'updateList', 'FUNC_9': 'setAnimal', 'FUNC_10': 'asSingleSelect', 'VAR_7': 'event', 'FUNC_11': 'getValue', 'FUNC_12': 'setItems', 'FUNC_13': 'findAll'} | java | Procedural | 37.18% |
package com.smartsoftasia.module.gblibrary.database;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
import com.j256.ormlite.dao.GenericRawResults;
import com.j256.ormlite.stmt.QueryBuilder;
import com.j256.ormlite.stmt.UpdateBuilder;
import com.j256.ormlite.table.TableUtils;
import com.path.android.jobqueue.Job;
import com.path.android.jobqueue.Params;
import android.content.Context;
/**
* The type Database manager.
* @param <T> the type parameter
* @author <NAME>
* @file MeetingDatabaseManager.java
* @date 12 oct. 2013
*/
public class DatabaseManager<T extends DatabaseModel> implements IRepository<T> {
private DatabaseHelper<T> helper;
/**
* Instantiates a new Database manager.
*
* @param context the context
* @param TClass the t class
* @param mList the m list
* @param databaseName the database name
* @param databaseVersion the database version
*/
protected DatabaseManager(Context context, Class<T> TClass, List<Object> mList, String databaseName, int databaseVersion) {
helper = new DatabaseHelper<T>(context, TClass, mList,databaseName,databaseVersion);
//helper = new DatabaseHelper<T>(context, TClass, dbName, dbVersion);
}
/**
* Gets helper.
*
* @return the helper
*/
public DatabaseHelper<T> getHelper() {
return helper;
}
@Override
public List<T> GetAll() {
List<T> items = null;
try {
items = getHelper().getDao().queryForEq(DatabaseModel.ENABLE, true);
} catch (SQLException e) {
e.printStackTrace();
}
return items;
}
@Override
public T GetById(int id) {
T items = null;
try {
items = getHelper().getDao().queryForId(id);
} catch (SQLException e) {
e.printStackTrace();
}
return items;
}
@Override
public void Update(T entite) {
try {
getHelper().getDao().update(entite);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void Delete(T entite) {
try {
getHelper().getDao().delete(entite);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void DeleteAll() {
try {
// getHelper().getDao().delete(this.GetAll());
TableUtils.clearTable(getHelper().getDao().getConnectionSource(), getHelper().getDao().getDataClass());
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void refresh(T entite) {
try {
getHelper().getDao().refresh(entite);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void CreateOrUpdate(T entite) {
try {
getHelper().getDao().createOrUpdate(entite);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void Add(T entite) {
try {
getHelper().getDao().create(entite);
} catch (SQLException e) {
e.printStackTrace();
}
}
public T MaxCreatedAt(){
T items = null;
try{
QueryBuilder<T,Integer> qBuilder = getHelper().getDao().queryBuilder();
qBuilder.orderBy(DatabaseModel.UPDATED_AT, false);// false for descending order
qBuilder.limit(1l);
List<T> listOfOne = qBuilder.query();
if(listOfOne!=null && listOfOne.size()>0){
items = listOfOne.get(0);
}
}catch (SQLException e){
e.printStackTrace();
}
return items;
}
/**
* Save list.
* Set ENABLE COLUMN to true before saving.
* This method work on job.
* @param list the list
*/
public void saveList(final Collection<T> list){
class SaveTask extends Job {
public static final int PRIORITY = 2;
protected SaveTask(Params params) {
super(new Params(PRIORITY).groupBy(JobHandler.DATABASE_GROUP));
}
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
if(list == null) return;
for(T item : list){
item.enable = true;
CreateOrUpdate(item);
}
}
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return false;
}
}
JobHandler.getInstance(helper.getContext()).getJobManager().addJobInBackground(new SaveTask(null));
}
/**
* Save void.
* Set ENABLE COLUMN to true before saving.
* This method work on job.
*
* @param item the item
*/
public void save(final T item){
class SaveTask extends Job {
public static final int PRIORITY = 2;
protected SaveTask(Params params) {
super(new Params(PRIORITY).groupBy(JobHandler.DATABASE_GROUP));
}
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
item.enable = true;
CreateOrUpdate(item);
}
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return false;
}
}
JobHandler.getInstance(helper.getContext()).getJobManager().addJobInBackground(new SaveTask(null));
}
/**
* Save void.
* Set ENABLE COLUMN to true before saving.
* This method work on job.
*
* @param id the id of the item
*/
public void delete(final int id){
class SaveTask extends Job {
public static final int PRIORITY = 2;
protected SaveTask(Params params) {
super(new Params(PRIORITY).groupBy(JobHandler.DATABASE_GROUP));
}
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
T item = GetById(id);
if(item != null){
Delete(item);
}
}
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return false;
}
}
JobHandler.getInstance(helper.getContext()).getJobManager().addJobInBackground(new SaveTask(null));
}
/**
* Gets all.
* Only is ENALBE column is set to true.
*This method work on job.
* @param listener the listener
*/
public void getAll(IDatabase.OnGetAll<T> listener) {
class Task extends Job {
public static final int PRIORITY = 2;
private IDatabase.OnGetAll<T> listener;
protected Task(Params params, IDatabase.OnGetAll<T> listener) {
super(new Params(PRIORITY).groupBy(JobHandler.DATABASE_GROUP));
this.listener = listener;
}
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
if(listener!=null) listener.onGetAll(DatabaseManager.this.GetAll());
}
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return false;
}
}
JobHandler.getInstance(helper.getContext()).getJobManager().addJobInBackground(new Task(null,listener ));
}
/**
* Gets by id.
* Regardless ENEBLE column.
*This method work on job.
*
* @param id the id
* @param listener the listener
*/
public void getById(int id, IDatabase.OnGetById<T> listener) {
class Task extends Job {
public static final int PRIORITY = 2;
private IDatabase.OnGetById<T> listener;
private int id;
protected Task(int id, IDatabase.OnGetById<T> listener) {
super(new Params(PRIORITY).groupBy(JobHandler.DATABASE_GROUP));
this.listener = listener;
this.id = id;
}
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
if(listener!=null) listener.onGetById(DatabaseManager.this.GetById(id));
}
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return false;
}
}
JobHandler.getInstance(helper.getContext()).getJobManager().addJobInBackground(new Task(id, listener));
}
/**
* Disable all.
* Set the ENABLE column to false for all the table
* This method work on job.
*
* @param listener the listener
*/
public void disableAll(IDatabase.OnDisableAll listener) {
class Task extends Job {
public static final int PRIORITY = 2;
private IDatabase.OnDisableAll listener;
protected Task(IDatabase.OnDisableAll listener) {
super(new Params(PRIORITY).groupBy(JobHandler.DATABASE_GROUP));
this.listener = listener;
}
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
UpdateBuilder<T, Integer> updateBuilder = getHelper().getDao().updateBuilder();
updateBuilder.where().ge(DatabaseModel.ID, 0);
updateBuilder.updateColumnValue(DatabaseModel.ENABLE, false);
updateBuilder.update();
}
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return false;
}
}
JobHandler.getInstance(helper.getContext()).getJobManager().addJobInBackground(new Task(listener));
if(listener!=null) listener.onDisableAll();
}
/**
* The interface I database.
*/
public interface IDatabase{
/**
* The interface On search.
* @param <T> the type parameter
*/
public interface OnSearch<T>{
/**
* On search.
*
* @param results the results
*/
public void onSearch(List<T>results);
}
/**
* The interface On get all.
* @param <T> the type parameter
*/
public interface OnGetAll<T>{
/**
* On get all.
*
* @param results the results
*/
public void onGetAll(List<T>results);
}
/**
* The interface On get by id.
* @param <T> the type parameter
*/
public interface OnGetById<T>{
/**
* On get by id.
*
* @param result the result
*/
public void onGetById(T result);
}
/**
* The interface On disable all.
*/
public interface OnDisableAll{
/**
* On disable all.
*/
public void onDisableAll();
}
}
}
| package com.smartsoftasia.module.gblibrary.database;
import java.sql.SQLException;
import java.util.Collection;
import java.util.List;
import com.j256.ormlite.dao.GenericRawResults;
import com.j256.ormlite.stmt.QueryBuilder;
import com.j256.ormlite.stmt.UpdateBuilder;
import com.j256.ormlite.table.TableUtils;
import com.path.android.jobqueue.Job;
import com.path.android.jobqueue.Params;
import android.content.Context;
/**
* The type Database manager.
* @param <T> the type parameter
* @author <NAME>
* @file MeetingDatabaseManager.java
* @date 12 oct. 2013
*/
public class DatabaseManager<T extends DatabaseModel> implements IRepository<T> {
private DatabaseHelper<T> helper;
/**
* Instantiates a new Database manager.
*
* @param context the context
* @param TClass the t class
* @param mList the m list
* @param databaseName the database name
* @param databaseVersion the database version
*/
protected DatabaseManager(Context context, Class<T> TClass, List<Object> mList, String databaseName, int databaseVersion) {
helper = new DatabaseHelper<T>(context, TClass, mList,databaseName,databaseVersion);
//helper = new DatabaseHelper<T>(context, TClass, dbName, dbVersion);
}
/**
* Gets helper.
*
* @return the helper
*/
public DatabaseHelper<T> getHelper() {
return helper;
}
@Override
public List<T> GetAll() {
List<T> items = null;
try {
items = getHelper().getDao().queryForEq(DatabaseModel.ENABLE, true);
} catch (SQLException e) {
e.printStackTrace();
}
return items;
}
@Override
public T GetById(int id) {
T items = null;
try {
items = getHelper().getDao().queryForId(id);
} catch (SQLException e) {
e.printStackTrace();
}
return items;
}
@Override
public void Update(T entite) {
try {
getHelper().getDao().update(entite);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void Delete(T entite) {
try {
getHelper().getDao().delete(entite);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void DeleteAll() {
try {
// getHelper().getDao().delete(this.GetAll());
TableUtils.clearTable(getHelper().getDao().getConnectionSource(), getHelper().getDao().getDataClass());
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void refresh(T entite) {
try {
getHelper().getDao().refresh(entite);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void FUNC_0(T entite) {
try {
getHelper().getDao().createOrUpdate(entite);
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
public void Add(T entite) {
try {
getHelper().getDao().create(entite);
} catch (SQLException e) {
e.printStackTrace();
}
}
public T MaxCreatedAt(){
T items = null;
try{
QueryBuilder<T,Integer> qBuilder = getHelper().getDao().queryBuilder();
qBuilder.orderBy(DatabaseModel.UPDATED_AT, false);// false for descending order
qBuilder.limit(1l);
List<T> listOfOne = qBuilder.query();
if(listOfOne!=null && listOfOne.size()>0){
items = listOfOne.get(0);
}
}catch (SQLException e){
e.printStackTrace();
}
return items;
}
/**
* Save list.
* Set ENABLE COLUMN to true before saving.
* This method work on job.
* @param list the list
*/
public void saveList(final Collection<T> list){
class SaveTask extends Job {
public static final int PRIORITY = 2;
protected SaveTask(Params params) {
super(new Params(PRIORITY).groupBy(JobHandler.DATABASE_GROUP));
}
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
if(list == null) return;
for(T item : list){
item.enable = true;
FUNC_0(item);
}
}
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return false;
}
}
JobHandler.getInstance(helper.getContext()).getJobManager().addJobInBackground(new SaveTask(null));
}
/**
* Save void.
* Set ENABLE COLUMN to true before saving.
* This method work on job.
*
* @param item the item
*/
public void save(final T item){
class SaveTask extends Job {
public static final int PRIORITY = 2;
protected SaveTask(Params params) {
super(new Params(PRIORITY).groupBy(JobHandler.DATABASE_GROUP));
}
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
item.enable = true;
FUNC_0(item);
}
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return false;
}
}
JobHandler.getInstance(helper.getContext()).getJobManager().addJobInBackground(new SaveTask(null));
}
/**
* Save void.
* Set ENABLE COLUMN to true before saving.
* This method work on job.
*
* @param id the id of the item
*/
public void delete(final int id){
class SaveTask extends Job {
public static final int PRIORITY = 2;
protected SaveTask(Params params) {
super(new Params(PRIORITY).groupBy(JobHandler.DATABASE_GROUP));
}
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
T item = GetById(id);
if(item != null){
Delete(item);
}
}
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return false;
}
}
JobHandler.getInstance(helper.getContext()).getJobManager().addJobInBackground(new SaveTask(null));
}
/**
* Gets all.
* Only is ENALBE column is set to true.
*This method work on job.
* @param listener the listener
*/
public void getAll(IDatabase.OnGetAll<T> listener) {
class Task extends Job {
public static final int PRIORITY = 2;
private IDatabase.OnGetAll<T> listener;
protected Task(Params params, IDatabase.OnGetAll<T> listener) {
super(new Params(PRIORITY).groupBy(JobHandler.DATABASE_GROUP));
this.listener = listener;
}
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
if(listener!=null) listener.onGetAll(DatabaseManager.this.GetAll());
}
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return false;
}
}
JobHandler.getInstance(helper.getContext()).getJobManager().addJobInBackground(new Task(null,listener ));
}
/**
* Gets by id.
* Regardless ENEBLE column.
*This method work on job.
*
* @param id the id
* @param listener the listener
*/
public void getById(int id, IDatabase.OnGetById<T> listener) {
class Task extends Job {
public static final int PRIORITY = 2;
private IDatabase.OnGetById<T> listener;
private int id;
protected Task(int id, IDatabase.OnGetById<T> listener) {
super(new Params(PRIORITY).groupBy(JobHandler.DATABASE_GROUP));
this.listener = listener;
this.id = id;
}
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
if(listener!=null) listener.onGetById(DatabaseManager.this.GetById(id));
}
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return false;
}
}
JobHandler.getInstance(helper.getContext()).getJobManager().addJobInBackground(new Task(id, listener));
}
/**
* Disable all.
* Set the ENABLE column to false for all the table
* This method work on job.
*
* @param listener the listener
*/
public void disableAll(IDatabase.OnDisableAll listener) {
class Task extends Job {
public static final int PRIORITY = 2;
private IDatabase.OnDisableAll listener;
protected Task(IDatabase.OnDisableAll listener) {
super(new Params(PRIORITY).groupBy(JobHandler.DATABASE_GROUP));
this.listener = listener;
}
@Override
public void onAdded() {
}
@Override
public void onRun() throws Throwable {
UpdateBuilder<T, Integer> updateBuilder = getHelper().getDao().updateBuilder();
updateBuilder.where().ge(DatabaseModel.ID, 0);
updateBuilder.updateColumnValue(DatabaseModel.ENABLE, false);
updateBuilder.update();
}
@Override
protected void onCancel() {
}
@Override
protected boolean shouldReRunOnThrowable(Throwable throwable) {
return false;
}
}
JobHandler.getInstance(helper.getContext()).getJobManager().addJobInBackground(new Task(listener));
if(listener!=null) listener.onDisableAll();
}
/**
* The interface I database.
*/
public interface IDatabase{
/**
* The interface On search.
* @param <T> the type parameter
*/
public interface OnSearch<T>{
/**
* On search.
*
* @param results the results
*/
public void onSearch(List<T>VAR_0);
}
/**
* The interface On get all.
* @param <T> the type parameter
*/
public interface OnGetAll<T>{
/**
* On get all.
*
* @param results the results
*/
public void onGetAll(List<T>VAR_0);
}
/**
* The interface On get by id.
* @param <T> the type parameter
*/
public interface OnGetById<T>{
/**
* On get by id.
*
* @param result the result
*/
public void onGetById(T result);
}
/**
* The interface On disable all.
*/
public interface OnDisableAll{
/**
* On disable all.
*/
public void onDisableAll();
}
}
}
| 0.01356 | {'FUNC_0': 'CreateOrUpdate', 'VAR_0': 'results'} | java | OOP | 22.01% |
package com.han.wanandroid.broadcast;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.han.wanandroid.utils.baseutils.LogUtils;
/**
* Created by hans
* e-mail: <EMAIL>
*/
public class TimeReceiver extends BroadcastReceiver {
private String TAG = "TimeReceiver";
@Override
public void onReceive(Context context, Intent intent) {
LogUtils.e(TAG, "TimeReceiver onReceive");
}
}
| package IMPORT_0.IMPORT_1.wanandroid.IMPORT_2;
import IMPORT_3.IMPORT_4.BroadcastReceiver;
import IMPORT_3.IMPORT_4.Context;
import IMPORT_3.IMPORT_4.IMPORT_5;
import IMPORT_0.IMPORT_1.wanandroid.IMPORT_6.IMPORT_7.IMPORT_8;
/**
* Created by hans
* e-mail: <EMAIL>
*/
public class TimeReceiver extends BroadcastReceiver {
private CLASS_0 VAR_0 = "TimeReceiver";
@VAR_1
public void onReceive(Context VAR_2, IMPORT_5 VAR_3) {
IMPORT_8.FUNC_0(VAR_0, "TimeReceiver onReceive");
}
}
| 0.580275 | {'IMPORT_0': 'com', 'IMPORT_1': 'han', 'IMPORT_2': 'broadcast', 'IMPORT_3': 'android', 'IMPORT_4': 'content', 'IMPORT_5': 'Intent', 'IMPORT_6': 'utils', 'IMPORT_7': 'baseutils', 'IMPORT_8': 'LogUtils', 'CLASS_0': 'String', 'VAR_0': 'TAG', 'VAR_1': 'Override', 'VAR_2': 'context', 'VAR_3': 'intent', 'FUNC_0': 'e'} | java | OOP | 100.00% |
/*
* Copyright 2015 Duanze
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.duanze.litepreferences.model;
/**
* Created by Duanze on 2015/11/20.
* <p>
* Model to express a Preference.
* It's easy,just go to see the source code.
*/
public class Pref {
public String key;
/**
* use String store the default value
*/
public String defValue;
/**
* use String store the current value
*/
public String curValue;
/**
* flag to show the pref has queried its data from SharedPreferences or not
*/
public boolean queried = false;
public Pref() {
}
public Pref(String key, String defValue) {
this.key = key;
this.defValue = defValue;
}
public Pref(String key, int defValue) {
this.key = key;
this.defValue = String.valueOf(defValue);
}
public Pref(String key, long defValue) {
this.key = key;
this.defValue = String.valueOf(defValue);
}
public Pref(String key, float defValue) {
this.key = key;
this.defValue = String.valueOf(defValue);
}
public Pref(String key, boolean defValue) {
this.key = key;
this.defValue = String.valueOf(defValue);
}
public int getDefInt() {
return Integer.parseInt(defValue);
}
public long getDefLong() {
return Long.parseLong(defValue);
}
public float getDefFloat() {
return Float.parseFloat(defValue);
}
public boolean getDefBoolean() {
return Boolean.parseBoolean(defValue);
}
public String getDefString() {
return defValue;
}
public int getCurInt() {
return Integer.parseInt(curValue);
}
public long getCurLong() {
return Long.parseLong(curValue);
}
public float getCurFloat() {
return Float.parseFloat(curValue);
}
public boolean getCurBoolean() {
return Boolean.parseBoolean(curValue);
}
public String getCurString() {
return curValue;
}
public void setValue(int value) {
curValue = String.valueOf(value);
}
public void setValue(long value) {
curValue = String.valueOf(value);
}
public void setValue(float value) {
curValue = String.valueOf(value);
}
public void setValue(boolean value) {
curValue = String.valueOf(value);
}
public void setValue(String value) {
curValue = value;
}
}
| /*
* Copyright 2015 Duanze
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.duanze.litepreferences.model;
/**
* Created by Duanze on 2015/11/20.
* <p>
* Model to express a Preference.
* It's easy,just go to see the source code.
*/
public class Pref {
public String key;
/**
* use String store the default value
*/
public String defValue;
/**
* use String store the current value
*/
public String curValue;
/**
* flag to show the pref has queried its data from SharedPreferences or not
*/
public boolean queried = false;
public Pref() {
}
public Pref(String key, String defValue) {
this.key = key;
this.defValue = defValue;
}
public Pref(String key, int defValue) {
this.key = key;
this.defValue = String.valueOf(defValue);
}
public Pref(String key, long defValue) {
this.key = key;
this.defValue = String.valueOf(defValue);
}
public Pref(String key, float defValue) {
this.key = key;
this.defValue = String.valueOf(defValue);
}
public Pref(String key, boolean defValue) {
this.key = key;
this.defValue = String.valueOf(defValue);
}
public int getDefInt() {
return Integer.parseInt(defValue);
}
public long getDefLong() {
return Long.parseLong(defValue);
}
public float getDefFloat() {
return Float.parseFloat(defValue);
}
public boolean getDefBoolean() {
return Boolean.parseBoolean(defValue);
}
public String getDefString() {
return defValue;
}
public int getCurInt() {
return Integer.parseInt(curValue);
}
public long getCurLong() {
return Long.parseLong(curValue);
}
public float getCurFloat() {
return Float.parseFloat(curValue);
}
public boolean getCurBoolean() {
return Boolean.parseBoolean(curValue);
}
public String getCurString() {
return curValue;
}
public void setValue(int value) {
curValue = String.valueOf(value);
}
public void setValue(long value) {
curValue = String.valueOf(value);
}
public void setValue(float value) {
curValue = String.valueOf(value);
}
public void setValue(boolean value) {
curValue = String.valueOf(value);
}
public void setValue(String value) {
curValue = value;
}
}
| 0.114962 | {} | java | Hibrido | 100.00% |
/*
* Copyright (c) 2010-2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.integrationstudio.maven.multi.module.handlers;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.apache.maven.model.Parent;
import org.apache.maven.project.MavenProject;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.wso2.integrationstudio.logging.core.IIntegrationStudioLog;
import org.wso2.integrationstudio.logging.core.Logger;
import org.wso2.integrationstudio.maven.multi.module.Activator;
import org.wso2.integrationstudio.maven.util.MavenUtils;
import org.wso2.integrationstudio.platform.core.model.AbstractListDataProvider;
import org.wso2.integrationstudio.platform.core.project.model.ProjectDataModel;
import org.wso2.integrationstudio.platform.core.utils.Constants;
import org.wso2.integrationstudio.utils.file.FileUtils;
public class MavenParentProjectList extends AbstractListDataProvider {
private static IIntegrationStudioLog log = Logger.getLog(Activator.PLUGIN_ID);
public List<ListData> getListData(String modelProperty, ProjectDataModel model) {
List<ListData> list = new ArrayList<ListData>();
boolean requiredParent = ((MvnMultiModuleModel) model).isRequiredParent();
boolean updateMode = ((MvnMultiModuleModel) model).isUpdateMode();
if (requiredParent && !updateMode) {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IProject[] projects = root.getProjects();
for (IProject project : projects) {
try {
if (project.isOpen() && project.hasNature(Constants.MAVEN_MULTI_MODULE_PROJECT_NATURE)) {
File pomFile = project.getFile("pom.xml").getLocation().toFile();
if (pomFile.exists()) {
MavenProject mavenProject = MavenUtils.getMavenProject(pomFile);
if (mavenProject.getPackaging().equals("pom")) {
Parent parent = new Parent();
parent.setArtifactId(mavenProject.getArtifactId());
parent.setGroupId(mavenProject.getGroupId());
parent.setVersion(mavenProject.getVersion());
try {
String relativePath = FileUtils.getRelativePath(model.getLocation(), pomFile);
if (relativePath.equals("pom.xml")) {
relativePath = "../" + relativePath;
}
parent.setRelativePath(relativePath);
ListData data = new ListData(parent.getArtifactId(), parent);
list.add(data);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
}
} catch (Exception e) {
log.error("Error reading project list", e);
}
}
}
return list;
}
private void setLocationOfCurrentSelection(ProjectDataModel model) {
IProject selectedProject = MavenPropertyTester.getSelectedProjectToCreateMMM();
File location;
if (selectedProject != null) {
location = selectedProject.getLocation().toFile();
} else {
location = ResourcesPlugin.getWorkspace().getRoot().getLocation().toFile();
}
model.setLocation(location);
}
}
| /*
* Copyright (c) 2010-2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wso2.IMPORT_0.maven.multi.module.handlers;
import java.io.IMPORT_1;
import java.util.IMPORT_2;
import java.util.IMPORT_3;
import org.apache.maven.IMPORT_4.Parent;
import org.apache.maven.IMPORT_5.IMPORT_6;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.wso2.IMPORT_0.logging.core.IIntegrationStudioLog;
import org.wso2.IMPORT_0.logging.core.Logger;
import org.wso2.IMPORT_0.maven.multi.module.Activator;
import org.wso2.IMPORT_0.maven.util.IMPORT_7;
import org.wso2.IMPORT_0.platform.core.IMPORT_4.AbstractListDataProvider;
import org.wso2.IMPORT_0.platform.core.IMPORT_5.IMPORT_4.ProjectDataModel;
import org.wso2.IMPORT_0.platform.core.utils.Constants;
import org.wso2.IMPORT_0.utils.file.FileUtils;
public class MavenParentProjectList extends AbstractListDataProvider {
private static IIntegrationStudioLog log = Logger.getLog(Activator.PLUGIN_ID);
public IMPORT_3<ListData> getListData(String modelProperty, ProjectDataModel IMPORT_4) {
IMPORT_3<ListData> list = new IMPORT_2<ListData>();
boolean requiredParent = ((MvnMultiModuleModel) IMPORT_4).isRequiredParent();
boolean updateMode = ((MvnMultiModuleModel) IMPORT_4).isUpdateMode();
if (requiredParent && !updateMode) {
IWorkspace workspace = ResourcesPlugin.FUNC_0();
IWorkspaceRoot root = workspace.getRoot();
IProject[] projects = root.getProjects();
for (IProject IMPORT_5 : projects) {
try {
if (IMPORT_5.isOpen() && IMPORT_5.hasNature(Constants.VAR_0)) {
IMPORT_1 pomFile = IMPORT_5.FUNC_1("pom.xml").getLocation().toFile();
if (pomFile.exists()) {
IMPORT_6 VAR_1 = IMPORT_7.FUNC_2(pomFile);
if (VAR_1.getPackaging().equals("pom")) {
Parent parent = new Parent();
parent.FUNC_3(VAR_1.FUNC_4());
parent.setGroupId(VAR_1.FUNC_5());
parent.setVersion(VAR_1.FUNC_6());
try {
String relativePath = FileUtils.getRelativePath(IMPORT_4.getLocation(), pomFile);
if (relativePath.equals("pom.xml")) {
relativePath = "../" + relativePath;
}
parent.FUNC_7(relativePath);
ListData VAR_2 = new ListData(parent.FUNC_4(), parent);
list.add(VAR_2);
} catch (CLASS_0 e) {
log.error(e.getMessage(), e);
}
}
}
}
} catch (CLASS_0 e) {
log.error("Error reading project list", e);
}
}
}
return list;
}
private void FUNC_8(ProjectDataModel IMPORT_4) {
IProject VAR_3 = MavenPropertyTester.getSelectedProjectToCreateMMM();
IMPORT_1 location;
if (VAR_3 != null) {
location = VAR_3.getLocation().toFile();
} else {
location = ResourcesPlugin.FUNC_0().getRoot().getLocation().toFile();
}
IMPORT_4.setLocation(location);
}
}
| 0.214091 | {'IMPORT_0': 'integrationstudio', 'IMPORT_1': 'File', 'IMPORT_2': 'ArrayList', 'IMPORT_3': 'List', 'IMPORT_4': 'model', 'IMPORT_5': 'project', 'IMPORT_6': 'MavenProject', 'IMPORT_7': 'MavenUtils', 'FUNC_0': 'getWorkspace', 'VAR_0': 'MAVEN_MULTI_MODULE_PROJECT_NATURE', 'FUNC_1': 'getFile', 'VAR_1': 'mavenProject', 'FUNC_2': 'getMavenProject', 'FUNC_3': 'setArtifactId', 'FUNC_4': 'getArtifactId', 'FUNC_5': 'getGroupId', 'FUNC_6': 'getVersion', 'FUNC_7': 'setRelativePath', 'VAR_2': 'data', 'CLASS_0': 'Exception', 'FUNC_8': 'setLocationOfCurrentSelection', 'VAR_3': 'selectedProject'} | java | Hibrido | 48.18% |
/*
* Copyright 2014-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.view;
public abstract class DisplayList {
public static final int FLAG_CLIP_CHILDREN = 0x1;
public abstract HardwareCanvas start();
public abstract HardwareCanvas start(int width, int height);
public abstract void end();
public abstract void clear();
public abstract int getSize();
public abstract void setLeftTopRightBottom(int left, int top, int right, int bottom);
public abstract void setTranslationX(float translationX);
public abstract void setTranslationY(float translationY);
public abstract boolean isValid();
public abstract void invalidate();
public abstract void setClipChildren(boolean clipChildren);
public abstract void setClipToBounds(boolean clipToBounds);
}
| /*
* Copyright 2014-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package IMPORT_0.view;
public abstract class CLASS_0 {
public static final int VAR_0 = 0x1;
public abstract CLASS_1 start();
public abstract CLASS_1 start(int VAR_1, int VAR_2);
public abstract void FUNC_0();
public abstract void FUNC_1();
public abstract int FUNC_2();
public abstract void FUNC_3(int VAR_3, int VAR_4, int VAR_5, int VAR_6);
public abstract void setTranslationX(float VAR_7);
public abstract void FUNC_4(float VAR_8);
public abstract boolean FUNC_5();
public abstract void FUNC_6();
public abstract void FUNC_7(boolean VAR_9);
public abstract void FUNC_8(boolean VAR_10);
}
| 0.719781 | {'IMPORT_0': 'android', 'CLASS_0': 'DisplayList', 'VAR_0': 'FLAG_CLIP_CHILDREN', 'CLASS_1': 'HardwareCanvas', 'VAR_1': 'width', 'VAR_2': 'height', 'FUNC_0': 'end', 'FUNC_1': 'clear', 'FUNC_2': 'getSize', 'FUNC_3': 'setLeftTopRightBottom', 'VAR_3': 'left', 'VAR_4': 'top', 'VAR_5': 'right', 'VAR_6': 'bottom', 'VAR_7': 'translationX', 'FUNC_4': 'setTranslationY', 'VAR_8': 'translationY', 'FUNC_5': 'isValid', 'FUNC_6': 'invalidate', 'FUNC_7': 'setClipChildren', 'VAR_9': 'clipChildren', 'FUNC_8': 'setClipToBounds', 'VAR_10': 'clipToBounds'} | java | Hibrido | 100.00% |
package net.spy.pool;
/**
* Exception thrown when there's a problem dealing with the pool.
*/
public class PoolException extends Exception {
/**
* Get a PoolException instance.
*/
public PoolException(String msg) {
super(msg);
}
/**
* Get a PoolException instance with a root cause.
*/
public PoolException(String msg, Throwable t) {
super(msg, t);
}
}
| package IMPORT_0.spy.IMPORT_1;
/**
* Exception thrown when there's a problem dealing with the pool.
*/
public class CLASS_0 extends Exception {
/**
* Get a PoolException instance.
*/
public CLASS_0(String msg) {
super(msg);
}
/**
* Get a PoolException instance with a root cause.
*/
public CLASS_0(String msg, Throwable t) {
super(msg, t);
}
}
| 0.25476 | {'IMPORT_0': 'net', 'IMPORT_1': 'pool', 'CLASS_0': 'PoolException'} | java | OOP | 100.00% |
/**
* Project : Retrofit
* Author : xicom
* Creation Date : 12-Feb-2014
* Description : @TODO
*/
package com.xicom.retrofit.activities;
import retrofit.Callback;
import retrofit.RetrofitError;
import retrofit.client.Response;
import android.app.ProgressDialog;
import android.content.Context;
import android.os.Handler;
import android.view.View;
import com.google.gson.GsonBuilder;
import com.xicom.retrofit.core.BaseActivity;
import com.xicom.retrofit.utils.GlobalVariables.SERVICE_MODE;
import com.xicom.retrofit.utils.Log4Android;
import com.xicom.retrofit.utils.UtilitySingleton;
public class MyCallback<T> implements Callback<T>
{
private final static String defaultMessage = "Loading";
public static final float DIALOG_OFFSET_MILISEC = 300;
private static ProgressDialog dialog;
private static int callCount;
private View v;
private BaseActivity<T> baseActivity;
private SERVICE_MODE mode;
/**
* Description : Callback with custom message
*/
@SuppressWarnings("unchecked")
public MyCallback(Context context, boolean showProgress, View v, String message, SERVICE_MODE mode)
{
this.baseActivity = (BaseActivity<T>) context;
this.mode = mode;
this.v = v;
v.setClickable(false);
if (showProgress)
{
StartProgress(message);
}
}
/**
* Description : Callback with default message
*/
public MyCallback(Context context, boolean showProgress, View v, SERVICE_MODE mode)
{
this(context, showProgress, v, defaultMessage, mode);
}
@Override
public void failure(RetrofitError error)
{
StopProgress();
if (error.isNetworkError())
{
//TODO What to show when network fails
error.printStackTrace();
Log4Android.e(this, "Network Failure==> " + error.getMessage());
}
else
{
Log4Android.e(this, "Failure==> " + UtilitySingleton.getInstance(baseActivity).getResponse(error.getResponse()));
}
baseActivity.failure(error, mode);
}
@Override
public void success(T model, Response arg1)
{
StopProgress();
ShowLog(model, arg1);
baseActivity.success(model, arg1, mode);
}
private void ShowLog(T model, Response arg1)
{
String body = UtilitySingleton.getInstance(baseActivity).getResponse(arg1);
System.out.println("headers :: "+arg1.getHeaders().get(0).toString());
Log4Android.l(this, "URL==> " + arg1.getUrl());
Log4Android.l(this, (body.equalsIgnoreCase("null")) ? "Model==> " + new GsonBuilder().setPrettyPrinting().create().toJson(model)
: "Body==> " + body);
}
public void StartProgress(String message)
{
if (dialog == null)
{
SetDialog(message);
callCount = 0;
}
callCount++;
if (dialog.isShowing())
{
dialog.setMessage(message);
}
else
{
new Handler().postDelayed(new Runnable()
{
@Override
public void run()
{
if (callCount > 0)
{
dialog.show();
}
}
}, (long) DIALOG_OFFSET_MILISEC);
}
}
public void StopProgress()
{
callCount--;
if (callCount <= 0)
{
v.setClickable(true);
if (dialog != null && dialog.isShowing())
{
dialog.dismiss();
}
}
}
private void SetDialog(String message)
{
dialog = new ProgressDialog(baseActivity);
dialog.setMessage(message);
dialog.setCancelable(false);
}
}
| /**
* Project : Retrofit
* Author : xicom
* Creation Date : 12-Feb-2014
* Description : @TODO
*/
package com.IMPORT_0.IMPORT_1.IMPORT_2;
import IMPORT_1.Callback;
import IMPORT_1.IMPORT_3;
import IMPORT_1.IMPORT_4.IMPORT_5;
import IMPORT_6.IMPORT_7.IMPORT_8;
import IMPORT_6.IMPORT_9.IMPORT_10;
import IMPORT_6.os.IMPORT_11;
import IMPORT_6.IMPORT_12.View;
import com.IMPORT_13.IMPORT_14.IMPORT_15;
import com.IMPORT_0.IMPORT_1.core.IMPORT_16;
import com.IMPORT_0.IMPORT_1.IMPORT_17.IMPORT_18.IMPORT_19;
import com.IMPORT_0.IMPORT_1.IMPORT_17.IMPORT_20;
import com.IMPORT_0.IMPORT_1.IMPORT_17.IMPORT_21;
public class CLASS_0<CLASS_1> implements Callback<CLASS_1>
{
private final static CLASS_2 defaultMessage = "Loading";
public static final float VAR_0 = 300;
private static IMPORT_8 VAR_1;
private static int VAR_2;
private View VAR_3;
private IMPORT_16<CLASS_1> VAR_4;
private IMPORT_19 mode;
/**
* Description : Callback with custom message
*/
@VAR_5("unchecked")
public CLASS_0(IMPORT_10 VAR_6, boolean VAR_7, View VAR_3, CLASS_2 VAR_8, IMPORT_19 mode)
{
this.VAR_4 = (IMPORT_16<CLASS_1>) VAR_6;
this.mode = mode;
this.VAR_3 = VAR_3;
VAR_3.FUNC_0(false);
if (VAR_7)
{
FUNC_1(VAR_8);
}
}
/**
* Description : Callback with default message
*/
public CLASS_0(IMPORT_10 VAR_6, boolean VAR_7, View VAR_3, IMPORT_19 mode)
{
this(VAR_6, VAR_7, VAR_3, defaultMessage, mode);
}
@VAR_9
public void FUNC_2(IMPORT_3 VAR_10)
{
FUNC_3();
if (VAR_10.FUNC_4())
{
//TODO What to show when network fails
VAR_10.FUNC_5();
IMPORT_20.FUNC_6(this, "Network Failure==> " + VAR_10.FUNC_7());
}
else
{
IMPORT_20.FUNC_6(this, "Failure==> " + IMPORT_21.FUNC_8(VAR_4).FUNC_9(VAR_10.FUNC_9()));
}
VAR_4.FUNC_2(VAR_10, mode);
}
@VAR_9
public void FUNC_10(CLASS_1 VAR_11, IMPORT_5 VAR_12)
{
FUNC_3();
ShowLog(VAR_11, VAR_12);
VAR_4.FUNC_10(VAR_11, VAR_12, mode);
}
private void ShowLog(CLASS_1 VAR_11, IMPORT_5 VAR_12)
{
CLASS_2 VAR_13 = IMPORT_21.FUNC_8(VAR_4).FUNC_9(VAR_12);
VAR_14.VAR_15.FUNC_11("headers :: "+VAR_12.FUNC_12().FUNC_13(0).FUNC_14());
IMPORT_20.FUNC_15(this, "URL==> " + VAR_12.FUNC_16());
IMPORT_20.FUNC_15(this, (VAR_13.FUNC_17("null")) ? "Model==> " + new IMPORT_15().FUNC_18().FUNC_19().FUNC_20(VAR_11)
: "Body==> " + VAR_13);
}
public void FUNC_1(CLASS_2 VAR_8)
{
if (VAR_1 == null)
{
FUNC_21(VAR_8);
VAR_2 = 0;
}
VAR_2++;
if (VAR_1.FUNC_22())
{
VAR_1.FUNC_23(VAR_8);
}
else
{
new IMPORT_11().FUNC_24(new CLASS_3()
{
@VAR_9
public void FUNC_25()
{
if (VAR_2 > 0)
{
VAR_1.FUNC_26();
}
}
}, (long) VAR_0);
}
}
public void FUNC_3()
{
VAR_2--;
if (VAR_2 <= 0)
{
VAR_3.FUNC_0(true);
if (VAR_1 != null && VAR_1.FUNC_22())
{
VAR_1.FUNC_27();
}
}
}
private void FUNC_21(CLASS_2 VAR_8)
{
VAR_1 = new IMPORT_8(VAR_4);
VAR_1.FUNC_23(VAR_8);
VAR_1.FUNC_28(false);
}
}
| 0.887315 | {'IMPORT_0': 'xicom', 'IMPORT_1': 'retrofit', 'IMPORT_2': 'activities', 'IMPORT_3': 'RetrofitError', 'IMPORT_4': 'client', 'IMPORT_5': 'Response', 'IMPORT_6': 'android', 'IMPORT_7': 'app', 'IMPORT_8': 'ProgressDialog', 'IMPORT_9': 'content', 'IMPORT_10': 'Context', 'IMPORT_11': 'Handler', 'IMPORT_12': 'view', 'IMPORT_13': 'google', 'IMPORT_14': 'gson', 'IMPORT_15': 'GsonBuilder', 'IMPORT_16': 'BaseActivity', 'IMPORT_17': 'utils', 'IMPORT_18': 'GlobalVariables', 'IMPORT_19': 'SERVICE_MODE', 'IMPORT_20': 'Log4Android', 'IMPORT_21': 'UtilitySingleton', 'CLASS_0': 'MyCallback', 'CLASS_1': 'T', 'CLASS_2': 'String', 'VAR_0': 'DIALOG_OFFSET_MILISEC', 'VAR_1': 'dialog', 'VAR_2': 'callCount', 'VAR_3': 'v', 'VAR_4': 'baseActivity', 'VAR_5': 'SuppressWarnings', 'VAR_6': 'context', 'VAR_7': 'showProgress', 'VAR_8': 'message', 'FUNC_0': 'setClickable', 'FUNC_1': 'StartProgress', 'VAR_9': 'Override', 'FUNC_2': 'failure', 'VAR_10': 'error', 'FUNC_3': 'StopProgress', 'FUNC_4': 'isNetworkError', 'FUNC_5': 'printStackTrace', 'FUNC_6': 'e', 'FUNC_7': 'getMessage', 'FUNC_8': 'getInstance', 'FUNC_9': 'getResponse', 'FUNC_10': 'success', 'VAR_11': 'model', 'VAR_12': 'arg1', 'VAR_13': 'body', 'VAR_14': 'System', 'VAR_15': 'out', 'FUNC_11': 'println', 'FUNC_12': 'getHeaders', 'FUNC_13': 'get', 'FUNC_14': 'toString', 'FUNC_15': 'l', 'FUNC_16': 'getUrl', 'FUNC_17': 'equalsIgnoreCase', 'FUNC_18': 'setPrettyPrinting', 'FUNC_19': 'create', 'FUNC_20': 'toJson', 'FUNC_21': 'SetDialog', 'FUNC_22': 'isShowing', 'FUNC_23': 'setMessage', 'FUNC_24': 'postDelayed', 'CLASS_3': 'Runnable', 'FUNC_25': 'run', 'FUNC_26': 'show', 'FUNC_27': 'dismiss', 'FUNC_28': 'setCancelable'} | java | OOP | 41.56% |
// "Remove redundant parameter" "true"
@interface Anno {
String[] foo() default {"One", "Two"};
}
@Anno(foo = {"One", <caret>"Two"})
class Foo {
}
| // "Remove redundant parameter" "true"
@interface Anno {
CLASS_0[] VAR_0() default {"One", "Two"};
}
@Anno(VAR_0 = {"One", <VAR_1>"Two"})
class CLASS_1 {
}
| 0.52066 | {'CLASS_0': 'String', 'VAR_0': 'foo', 'VAR_1': 'caret', 'CLASS_1': 'Foo'} | java | Texto | 13.64% |
/*
* Copyright (c) 2012 - 2020 Arvato Systems GmbH
*
* 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.arvatosystems.t9t.ssm;
import com.arvatosystems.t9t.base.T9tException;
/**
* This class contains all exception codes used in ssm module.
*/
public class T9tSsmException extends T9tException {
private static final long serialVersionUID = -2311386486424675268L;
/*
* Offset for all codes in this class.
*/
private static final int CORE_OFFSET = 22000;
private static final int OFFSET = (CL_PARAMETER_ERROR * CLASSIFICATION_FACTOR) + CORE_OFFSET;
@SuppressWarnings("unused")
private static final int OFFSET_LOGIC_ERROR = (CL_INTERNAL_LOGIC_ERROR * CLASSIFICATION_FACTOR) + CORE_OFFSET;
// CHECKSTYLE.OFF: JavadocVariable
// CHECKSTYLE.OFF: DeclarationOrder
// scheduler related exceptions
public static final int SERVICE_SESSION_OPEN_EXCEPTION = OFFSET + 200;
public static final int SCHEDULER_JOB_NOT_FOUND_EXCEPTION = OFFSET + 201;
public static final int SCHEDULER_INIT_OR_START_EXCEPTION = OFFSET + 202;
public static final int SCHEDULER_SHUTDOWN_EXCEPTION = OFFSET + 203;
public static final int SCHEDULER_DELETE_JOB_EXCEPTION = OFFSET + 204;
public static final int SCHEDULER_UPDATE_JOB_EXCEPTION = OFFSET + 205;
public static final int SCHEDULER_CREATE_JOB_EXCEPTION = OFFSET + 207;
public static final int SCHEDULER_READ_EXCEPTION = OFFSET + 208;
public static final int VALIDATION_CREATION_NO_TENANT_REF = OFFSET + 209;
public static final int SERVICESESSION_IS_NULL = OFFSET + 210;
public static final int SCHEDULER_JOB_EXECUTION_FAILURE = OFFSET + 211;
public static final int SCHEDULER_SETUP_FAILURE_INTERVAL = OFFSET + 212;
public static final int SCHEDULE_VALID_FROM_NOT_PROVIDED = OFFSET + 213;
public static final int SCHEDULE_EXECUTION_TIME_MISSING = OFFSET + 214;
public static final int SCHEDULE_CRON_EXPRESSION_MISSING = OFFSET + 215;
public static final int SCHEDULE_CRON_REGEX_PATTERN_MISMATCH = OFFSET + 216;
public static final int SCHEDULE_SETUP_INTERVAL_VALIDATION_ERR = OFFSET + 220;
public static final int IRRELEVANT_SCHEDULER_PARAM_ERR = OFFSET + 221;
public static final int REQUIRED_SCHEDULER_PARAM_MISSING = OFFSET + 222;
public static final int SCHEDULE_SETUP_PARAM_VALIDATION_ERR = OFFSET + 223;
/**
* static initialization of all error codes
*/
static {
codeToDescription.put(SCHEDULER_JOB_NOT_FOUND_EXCEPTION, "The scheduler contains not job with passed parameters.");
codeToDescription.put(SCHEDULER_INIT_OR_START_EXCEPTION, "The scheduler could not be started correctly.");
codeToDescription.put(SCHEDULER_SHUTDOWN_EXCEPTION, "The scheduler could not be shut down correctly.");
codeToDescription.put(SCHEDULER_DELETE_JOB_EXCEPTION, "The scheduler was not able to delete a job.");
codeToDescription.put(SCHEDULER_UPDATE_JOB_EXCEPTION, "The scheduler was not able to update a job.");
codeToDescription.put(SCHEDULER_CREATE_JOB_EXCEPTION, "The scheduler was not able to create a job.");
codeToDescription.put(SCHEDULER_READ_EXCEPTION, "The scheduler was not able to read a job.");
codeToDescription.put(SERVICE_SESSION_OPEN_EXCEPTION, "The service session could not be opened.");
codeToDescription.put(VALIDATION_CREATION_NO_TENANT_REF, "Tenant Ref has to be either in InternalHeaderParameters or in ReportDTO");
codeToDescription.put(SERVICESESSION_IS_NULL, "The service session for the job execution is null");
codeToDescription.put(SCHEDULER_JOB_EXECUTION_FAILURE, "Failed to execute job");
codeToDescription.put(SCHEDULER_SETUP_FAILURE_INTERVAL,
"If a minute interval should be used the fields for start hour, end hour and minute interval have to be filled");
codeToDescription.put(SCHEDULE_VALID_FROM_NOT_PROVIDED, "Please provided Valid From Date.");
codeToDescription.put(SCHEDULE_EXECUTION_TIME_MISSING, "Execution Time is missing");
codeToDescription.put(SCHEDULE_CRON_EXPRESSION_MISSING, "Required cronExpression is missing");
codeToDescription.put(SCHEDULE_CRON_REGEX_PATTERN_MISMATCH, "CRON native doesn't comply with CRON expression pattern");
codeToDescription.put(SCHEDULE_SETUP_INTERVAL_VALIDATION_ERR, "Interval parameter validation failed for the scheduler");
codeToDescription.put(IRRELEVANT_SCHEDULER_PARAM_ERR, "Found irrelevant scheduler parameter");
codeToDescription.put(REQUIRED_SCHEDULER_PARAM_MISSING, "Missing relevant scheduler parameter.");
codeToDescription.put(SCHEDULE_SETUP_PARAM_VALIDATION_ERR, "Validation on required setup parameter failed");
}
}
| /*
* Copyright (c) 2012 - 2020 Arvato Systems GmbH
*
* 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.arvatosystems.t9t.IMPORT_0;
import com.arvatosystems.t9t.base.IMPORT_1;
/**
* This class contains all exception codes used in ssm module.
*/
public class CLASS_0 extends IMPORT_1 {
private static final long serialVersionUID = -2311386486424675268L;
/*
* Offset for all codes in this class.
*/
private static final int VAR_0 = 22000;
private static final int OFFSET = (VAR_1 * CLASSIFICATION_FACTOR) + VAR_0;
@VAR_2("unused")
private static final int OFFSET_LOGIC_ERROR = (VAR_3 * CLASSIFICATION_FACTOR) + VAR_0;
// CHECKSTYLE.OFF: JavadocVariable
// CHECKSTYLE.OFF: DeclarationOrder
// scheduler related exceptions
public static final int VAR_4 = OFFSET + 200;
public static final int VAR_5 = OFFSET + 201;
public static final int VAR_6 = OFFSET + 202;
public static final int VAR_7 = OFFSET + 203;
public static final int SCHEDULER_DELETE_JOB_EXCEPTION = OFFSET + 204;
public static final int SCHEDULER_UPDATE_JOB_EXCEPTION = OFFSET + 205;
public static final int SCHEDULER_CREATE_JOB_EXCEPTION = OFFSET + 207;
public static final int VAR_8 = OFFSET + 208;
public static final int VAR_9 = OFFSET + 209;
public static final int SERVICESESSION_IS_NULL = OFFSET + 210;
public static final int VAR_10 = OFFSET + 211;
public static final int VAR_11 = OFFSET + 212;
public static final int SCHEDULE_VALID_FROM_NOT_PROVIDED = OFFSET + 213;
public static final int SCHEDULE_EXECUTION_TIME_MISSING = OFFSET + 214;
public static final int VAR_12 = OFFSET + 215;
public static final int VAR_13 = OFFSET + 216;
public static final int SCHEDULE_SETUP_INTERVAL_VALIDATION_ERR = OFFSET + 220;
public static final int VAR_14 = OFFSET + 221;
public static final int REQUIRED_SCHEDULER_PARAM_MISSING = OFFSET + 222;
public static final int SCHEDULE_SETUP_PARAM_VALIDATION_ERR = OFFSET + 223;
/**
* static initialization of all error codes
*/
static {
VAR_15.put(VAR_5, "The scheduler contains not job with passed parameters.");
VAR_15.put(VAR_6, "The scheduler could not be started correctly.");
VAR_15.put(VAR_7, "The scheduler could not be shut down correctly.");
VAR_15.put(SCHEDULER_DELETE_JOB_EXCEPTION, "The scheduler was not able to delete a job.");
VAR_15.put(SCHEDULER_UPDATE_JOB_EXCEPTION, "The scheduler was not able to update a job.");
VAR_15.put(SCHEDULER_CREATE_JOB_EXCEPTION, "The scheduler was not able to create a job.");
VAR_15.put(VAR_8, "The scheduler was not able to read a job.");
VAR_15.put(VAR_4, "The service session could not be opened.");
VAR_15.put(VAR_9, "Tenant Ref has to be either in InternalHeaderParameters or in ReportDTO");
VAR_15.put(SERVICESESSION_IS_NULL, "The service session for the job execution is null");
VAR_15.put(VAR_10, "Failed to execute job");
VAR_15.put(VAR_11,
"If a minute interval should be used the fields for start hour, end hour and minute interval have to be filled");
VAR_15.put(SCHEDULE_VALID_FROM_NOT_PROVIDED, "Please provided Valid From Date.");
VAR_15.put(SCHEDULE_EXECUTION_TIME_MISSING, "Execution Time is missing");
VAR_15.put(VAR_12, "Required cronExpression is missing");
VAR_15.put(VAR_13, "CRON native doesn't comply with CRON expression pattern");
VAR_15.put(SCHEDULE_SETUP_INTERVAL_VALIDATION_ERR, "Interval parameter validation failed for the scheduler");
VAR_15.put(VAR_14, "Found irrelevant scheduler parameter");
VAR_15.put(REQUIRED_SCHEDULER_PARAM_MISSING, "Missing relevant scheduler parameter.");
VAR_15.put(SCHEDULE_SETUP_PARAM_VALIDATION_ERR, "Validation on required setup parameter failed");
}
}
| 0.547441 | {'IMPORT_0': 'ssm', 'IMPORT_1': 'T9tException', 'CLASS_0': 'T9tSsmException', 'VAR_0': 'CORE_OFFSET', 'VAR_1': 'CL_PARAMETER_ERROR', 'VAR_2': 'SuppressWarnings', 'VAR_3': 'CL_INTERNAL_LOGIC_ERROR', 'VAR_4': 'SERVICE_SESSION_OPEN_EXCEPTION', 'VAR_5': 'SCHEDULER_JOB_NOT_FOUND_EXCEPTION', 'VAR_6': 'SCHEDULER_INIT_OR_START_EXCEPTION', 'VAR_7': 'SCHEDULER_SHUTDOWN_EXCEPTION', 'VAR_8': 'SCHEDULER_READ_EXCEPTION', 'VAR_9': 'VALIDATION_CREATION_NO_TENANT_REF', 'VAR_10': 'SCHEDULER_JOB_EXECUTION_FAILURE', 'VAR_11': 'SCHEDULER_SETUP_FAILURE_INTERVAL', 'VAR_12': 'SCHEDULE_CRON_EXPRESSION_MISSING', 'VAR_13': 'SCHEDULE_CRON_REGEX_PATTERN_MISMATCH', 'VAR_14': 'IRRELEVANT_SCHEDULER_PARAM_ERR', 'VAR_15': 'codeToDescription'} | java | Hibrido | 100.00% |
package cgeo.geocaching.sorting;
import cgeo.geocaching.models.Geocache;
import cgeo.geocaching.sensors.Sensors;
import cgeo.geocaching.utils.CalendarUtils;
import androidx.annotation.NonNull;
import java.util.ArrayList;
import java.util.Date;
/**
* compares caches by hidden date
*/
class DateComparator extends AbstractCacheComparator {
@Override
protected int compareCaches(final Geocache cache1, final Geocache cache2) {
final Date date1 = cache1.getHiddenDate();
final Date date2 = cache2.getHiddenDate();
if (date1 != null && date2 != null) {
final int dateDifference = date1.compareTo(date2);
if (dateDifference == 0) {
return sortSameDate(cache1, cache2);
}
return dateDifference;
}
if (date1 != null) {
return -1;
}
if (date2 != null) {
return 1;
}
return 0;
}
protected int sortSameDate(final Geocache cache1, final Geocache cache2) {
final ArrayList<Geocache> list = new ArrayList<>();
list.add(cache1);
list.add(cache2);
final DistanceComparator distanceComparator = new DistanceComparator(Sensors.getInstance().currentGeo().getCoords(), list);
return distanceComparator.compare(cache1, cache2);
}
@Override
public String getSortableSection(@NonNull final Geocache cache) {
return CalendarUtils.yearMonth(cache.getHiddenDate());
}
}
| package IMPORT_0.IMPORT_1.IMPORT_2;
import IMPORT_0.IMPORT_1.IMPORT_3.IMPORT_4;
import IMPORT_0.IMPORT_1.IMPORT_5.IMPORT_6;
import IMPORT_0.IMPORT_1.IMPORT_7.IMPORT_8;
import IMPORT_9.IMPORT_10.IMPORT_11;
import IMPORT_12.IMPORT_13.IMPORT_14;
import IMPORT_12.IMPORT_13.IMPORT_15;
/**
* compares caches by hidden date
*/
class CLASS_0 extends AbstractCacheComparator {
@VAR_0
protected int compareCaches(final IMPORT_4 VAR_1, final IMPORT_4 VAR_2) {
final IMPORT_15 date1 = VAR_1.getHiddenDate();
final IMPORT_15 VAR_3 = VAR_2.getHiddenDate();
if (date1 != null && VAR_3 != null) {
final int VAR_4 = date1.FUNC_0(VAR_3);
if (VAR_4 == 0) {
return sortSameDate(VAR_1, VAR_2);
}
return VAR_4;
}
if (date1 != null) {
return -1;
}
if (VAR_3 != null) {
return 1;
}
return 0;
}
protected int sortSameDate(final IMPORT_4 VAR_1, final IMPORT_4 VAR_2) {
final IMPORT_14<IMPORT_4> VAR_5 = new IMPORT_14<>();
VAR_5.add(VAR_1);
VAR_5.add(VAR_2);
final DistanceComparator VAR_6 = new DistanceComparator(IMPORT_6.FUNC_1().FUNC_2().FUNC_3(), VAR_5);
return VAR_6.FUNC_4(VAR_1, VAR_2);
}
@VAR_0
public CLASS_1 FUNC_5(@IMPORT_11 final IMPORT_4 cache) {
return IMPORT_8.FUNC_6(cache.getHiddenDate());
}
}
| 0.783649 | {'IMPORT_0': 'cgeo', 'IMPORT_1': 'geocaching', 'IMPORT_2': 'sorting', 'IMPORT_3': 'models', 'IMPORT_4': 'Geocache', 'IMPORT_5': 'sensors', 'IMPORT_6': 'Sensors', 'IMPORT_7': 'utils', 'IMPORT_8': 'CalendarUtils', 'IMPORT_9': 'androidx', 'IMPORT_10': 'annotation', 'IMPORT_11': 'NonNull', 'IMPORT_12': 'java', 'IMPORT_13': 'util', 'IMPORT_14': 'ArrayList', 'IMPORT_15': 'Date', 'CLASS_0': 'DateComparator', 'VAR_0': 'Override', 'VAR_1': 'cache1', 'VAR_2': 'cache2', 'VAR_3': 'date2', 'VAR_4': 'dateDifference', 'FUNC_0': 'compareTo', 'VAR_5': 'list', 'VAR_6': 'distanceComparator', 'FUNC_1': 'getInstance', 'FUNC_2': 'currentGeo', 'FUNC_3': 'getCoords', 'FUNC_4': 'compare', 'CLASS_1': 'String', 'FUNC_5': 'getSortableSection', 'FUNC_6': 'yearMonth'} | java | OOP | 80.00% |
package top.chengdongqing.common.kit;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.util.Map;
/**
* XML utility functions
*
* @author Luyao
*/
public class XmlKit {
/**
* Parses the xml to {@link Kv}
*
* @param xml the xml string to parse
* @return the {@link Kv} instance with the key-value mappings from the xml string
*/
public static Kv<String, String> parseXml(String xml) {
if (StrKit.isBlank(xml)) throw new IllegalArgumentException("The xml can not be blank");
Kv<String, String> params = new Kv<>();
try (InputStream is = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))) {
Document doc = newDocumentBuilder().parse(is);
doc.getDocumentElement().normalize();
NodeList nodes = doc.getDocumentElement().getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
params.add(node.getNodeName(), node.getTextContent());
}
}
return params;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Transforms the {@link Map} instance to xml string
*
* @param map the map to transform
* @return the xml string
*/
public static String toXml(Map<String, String> map) {
if (map == null || map.isEmpty()) throw new IllegalArgumentException("The map can not be null or empty");
try (StringWriter writer = new StringWriter()) {
Document document = newDocumentBuilder().newDocument();
Element root = document.createElement("xml");
map.forEach((key, value) -> {
if (StrKit.isNotBlank(value)) {
Element element = document.createElement(key);
element.appendChild(document.createTextNode(value));
root.appendChild(element);
}
});
document.appendChild(root);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
DOMSource source = new DOMSource(document);
transformer.setOutputProperty(OutputKeys.ENCODING, StandardCharsets.UTF_8.name());
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
StreamResult result = new StreamResult(writer);
transformer.transform(source, result);
return writer.toString();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Builds the xml document builder
*
* @return the built DocumentBuilder
*/
private static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
dbFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
dbFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
dbFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
// dbFactory.setFeature("http://javax.xml.XMLConfigs/feature/secure-processing", true);
dbFactory.setXIncludeAware(false);
dbFactory.setExpandEntityReferences(false);
return dbFactory.newDocumentBuilder();
}
}
| package top.chengdongqing.common.kit;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.util.Map;
/**
* XML utility functions
*
* @author Luyao
*/
public class XmlKit {
/**
* Parses the xml to {@link Kv}
*
* @param xml the xml string to parse
* @return the {@link Kv} instance with the key-value mappings from the xml string
*/
public static Kv<String, String> parseXml(String xml) {
if (StrKit.isBlank(xml)) throw new IllegalArgumentException("The xml can not be blank");
Kv<String, String> params = new Kv<>();
try (InputStream is = new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8))) {
Document doc = newDocumentBuilder().parse(is);
doc.FUNC_0().normalize();
NodeList nodes = doc.FUNC_0().getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Node node = nodes.item(i);
if (node.getNodeType() == Node.ELEMENT_NODE) {
params.add(node.getNodeName(), node.getTextContent());
}
}
return params;
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Transforms the {@link Map} instance to xml string
*
* @param map the map to transform
* @return the xml string
*/
public static String toXml(Map<String, String> VAR_0) {
if (VAR_0 == null || VAR_0.isEmpty()) throw new IllegalArgumentException("The map can not be null or empty");
try (StringWriter writer = new StringWriter()) {
Document document = newDocumentBuilder().newDocument();
Element root = document.createElement("xml");
VAR_0.forEach((key, value) -> {
if (StrKit.isNotBlank(value)) {
Element element = document.createElement(key);
element.appendChild(document.createTextNode(value));
root.appendChild(element);
}
});
document.appendChild(root);
Transformer transformer = TransformerFactory.newInstance().newTransformer();
DOMSource source = new DOMSource(document);
transformer.setOutputProperty(OutputKeys.ENCODING, StandardCharsets.UTF_8.name());
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
StreamResult result = new StreamResult(writer);
transformer.transform(source, result);
return writer.toString();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Builds the xml document builder
*
* @return the built DocumentBuilder
*/
private static DocumentBuilder newDocumentBuilder() throws ParserConfigurationException {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
dbFactory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
dbFactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
dbFactory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
dbFactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
// dbFactory.setFeature("http://javax.xml.XMLConfigs/feature/secure-processing", true);
dbFactory.setXIncludeAware(false);
dbFactory.setExpandEntityReferences(false);
return dbFactory.newDocumentBuilder();
}
}
| 0.030391 | {'FUNC_0': 'getDocumentElement', 'VAR_0': 'map'} | java | OOP | 28.35% |
package jetbrains.mps.lang.smodel.query.dataFlow;
/*Generated by MPS */
import jetbrains.mps.lang.dataFlow.DataFlowBuilder;
import jetbrains.mps.lang.dataFlow.DataFlowBuilderContext;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.lang.smodel.generator.smodelAdapter.SLinkOperations;
import org.jetbrains.mps.openapi.language.SContainmentLink;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
public class WithStatement_DataFlow extends DataFlowBuilder {
public void build(final DataFlowBuilderContext _context) {
_context.getBuilder().build((SNode) SLinkOperations.getTarget(_context.getNode(), LINKS.scope$iFuc));
_context.getBuilder().build((SNode) SLinkOperations.getTarget(_context.getNode(), LINKS.stmts$fOW2));
}
private static final class LINKS {
/*package*/ static final SContainmentLink scope$iFuc = MetaAdapterFactory.getContainmentLink(0x1a8554c4eb8443baL, 0x8c346f0d90c6e75aL, 0x3ac2ae2c0bcf368bL, 0x3ac2ae2c0bcf36b7L, "scope");
/*package*/ static final SContainmentLink stmts$fOW2 = MetaAdapterFactory.getContainmentLink(0x1a8554c4eb8443baL, 0x8c346f0d90c6e75aL, 0x3ac2ae2c0bcf368bL, 0x3ac2ae2c0bcf368cL, "stmts");
}
}
| package jetbrains.mps.lang.smodel.query.dataFlow;
/*Generated by MPS */
import jetbrains.mps.lang.dataFlow.DataFlowBuilder;
import jetbrains.mps.lang.dataFlow.DataFlowBuilderContext;
import org.jetbrains.mps.openapi.model.SNode;
import jetbrains.mps.lang.smodel.IMPORT_0.smodelAdapter.SLinkOperations;
import org.jetbrains.mps.openapi.language.IMPORT_1;
import jetbrains.mps.smodel.adapter.structure.MetaAdapterFactory;
public class WithStatement_DataFlow extends DataFlowBuilder {
public void FUNC_0(final DataFlowBuilderContext VAR_0) {
VAR_0.getBuilder().FUNC_0((SNode) SLinkOperations.FUNC_1(VAR_0.getNode(), LINKS.scope$iFuc));
VAR_0.getBuilder().FUNC_0((SNode) SLinkOperations.FUNC_1(VAR_0.getNode(), LINKS.stmts$fOW2));
}
private static final class LINKS {
/*package*/ static final IMPORT_1 scope$iFuc = MetaAdapterFactory.FUNC_2(0x1a8554c4eb8443baL, 0x8c346f0d90c6e75aL, 0x3ac2ae2c0bcf368bL, 0x3ac2ae2c0bcf36b7L, "scope");
/*package*/ static final IMPORT_1 stmts$fOW2 = MetaAdapterFactory.FUNC_2(0x1a8554c4eb8443baL, 0x8c346f0d90c6e75aL, 0x3ac2ae2c0bcf368bL, 0x3ac2ae2c0bcf368cL, "stmts");
}
}
| 0.234534 | {'IMPORT_0': 'generator', 'IMPORT_1': 'SContainmentLink', 'FUNC_0': 'build', 'VAR_0': '_context', 'FUNC_1': 'getTarget', 'FUNC_2': 'getContainmentLink'} | java | OOP | 50.34% |
/*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.popular.movies.data.database;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
/**
* Manages a local database for favorites movies data.
*/
class FavoritesDbHelper extends SQLiteOpenHelper {
/*
* This is the name of our database. Database names should be descriptive and end with the
* .db extension.
*/
private static final String DATABASE_NAME = "favorites.db";
/*
* If you change the database schema, you must increment the database version or the onUpgrade
* method will not be called.
*/
private static final int DATABASE_VERSION = 1;
FavoritesDbHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
/**
* Called when the database is created for the first time. This is where the creation of
* tables and the initial population of the tables should happen.
*
* @param sqLiteDatabase The database.
*/
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
/*
* This String will contain a simple SQL statement that will create a table that will
* cache our favorites.
*/
final String SQL_CREATE_FAVORITES_TABLE =
"CREATE TABLE " + FavoriteContract.FavoriteEntry.TABLE_NAME + " (" +
/*
* FavoriteEntry did not explicitly declare a column called "_ID". However,
* FavoriteEntry implements the interface, "BaseColumns", which does have a field
* named "_ID". We use that here to designate our table's primary key.
*/
FavoriteContract.FavoriteEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
FavoriteContract.FavoriteEntry.COLUMN_MOVIE_ID + " INT NOT NULL, " +
FavoriteContract.FavoriteEntry.COLUMN_ORIGINAL_TITLE + " TEXT NOT NULL, " +
FavoriteContract.FavoriteEntry.COLUMN_DURATION + " INT, " +
FavoriteContract.FavoriteEntry.COLUMN_RELEASE_DATE + " TEXT, " +
FavoriteContract.FavoriteEntry.COLUMN_POPULARITY + " REAL, " +
FavoriteContract.FavoriteEntry.COLUMN_RATING + " REAL, " +
FavoriteContract.FavoriteEntry.COLUMN_GENRES + " TEXT, " +
FavoriteContract.FavoriteEntry.COLUMN_STORYLINE + " TEXT, " +
FavoriteContract.FavoriteEntry.COLUMN_POSTER_PATH + " TEXT, " +
/*
* To ensure this table can only contain one Movie entry per id, we declare
* the date column to be unique. We also specify "ON CONFLICT REPLACE". This tells
* SQLite that if we have a favorite entry for a certain id and we attempt to
* insert another favorite entry with that id, we replace the old favorite entry.
*/
" UNIQUE (" + FavoriteContract.FavoriteEntry.COLUMN_MOVIE_ID + ") ON CONFLICT REPLACE);";
/*
* After we've spelled out our SQLite table creation statement above, we actually execute
* that SQL with the execSQL method of our SQLite database object.
*/
sqLiteDatabase.execSQL(SQL_CREATE_FAVORITES_TABLE);
}
/**
* This method discards the old table of data and calls onCreate to recreate a new one.
* This only occurs when the version number for this database (DATABASE_VERSION) is incremented.
*/
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + FavoriteContract.FavoriteEntry.TABLE_NAME);
onCreate(sqLiteDatabase);
}
} | /*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package IMPORT_0.popular.IMPORT_1.IMPORT_2.database;
import android.IMPORT_3.Context;
import android.database.IMPORT_4.SQLiteDatabase;
import android.database.IMPORT_4.IMPORT_5;
/**
* Manages a local database for favorites movies data.
*/
class CLASS_0 extends IMPORT_5 {
/*
* This is the name of our database. Database names should be descriptive and end with the
* .db extension.
*/
private static final CLASS_1 DATABASE_NAME = "favorites.db";
/*
* If you change the database schema, you must increment the database version or the onUpgrade
* method will not be called.
*/
private static final int VAR_0 = 1;
CLASS_0(Context VAR_1) {
super(VAR_1, DATABASE_NAME, null, VAR_0);
}
/**
* Called when the database is created for the first time. This is where the creation of
* tables and the initial population of the tables should happen.
*
* @param sqLiteDatabase The database.
*/
@VAR_2
public void onCreate(SQLiteDatabase VAR_3) {
/*
* This String will contain a simple SQL statement that will create a table that will
* cache our favorites.
*/
final CLASS_1 SQL_CREATE_FAVORITES_TABLE =
"CREATE TABLE " + FavoriteContract.VAR_4.VAR_5 + " (" +
/*
* FavoriteEntry did not explicitly declare a column called "_ID". However,
* FavoriteEntry implements the interface, "BaseColumns", which does have a field
* named "_ID". We use that here to designate our table's primary key.
*/
FavoriteContract.VAR_4._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
FavoriteContract.VAR_4.COLUMN_MOVIE_ID + " INT NOT NULL, " +
FavoriteContract.VAR_4.VAR_6 + " TEXT NOT NULL, " +
FavoriteContract.VAR_4.COLUMN_DURATION + " INT, " +
FavoriteContract.VAR_4.COLUMN_RELEASE_DATE + " TEXT, " +
FavoriteContract.VAR_4.VAR_7 + " REAL, " +
FavoriteContract.VAR_4.COLUMN_RATING + " REAL, " +
FavoriteContract.VAR_4.COLUMN_GENRES + " TEXT, " +
FavoriteContract.VAR_4.VAR_8 + " TEXT, " +
FavoriteContract.VAR_4.VAR_9 + " TEXT, " +
/*
* To ensure this table can only contain one Movie entry per id, we declare
* the date column to be unique. We also specify "ON CONFLICT REPLACE". This tells
* SQLite that if we have a favorite entry for a certain id and we attempt to
* insert another favorite entry with that id, we replace the old favorite entry.
*/
" UNIQUE (" + FavoriteContract.VAR_4.COLUMN_MOVIE_ID + ") ON CONFLICT REPLACE);";
/*
* After we've spelled out our SQLite table creation statement above, we actually execute
* that SQL with the execSQL method of our SQLite database object.
*/
VAR_3.execSQL(SQL_CREATE_FAVORITES_TABLE);
}
/**
* This method discards the old table of data and calls onCreate to recreate a new one.
* This only occurs when the version number for this database (DATABASE_VERSION) is incremented.
*/
@VAR_2
public void FUNC_0(SQLiteDatabase VAR_3, int VAR_10, int VAR_11) {
VAR_3.execSQL("DROP TABLE IF EXISTS " + FavoriteContract.VAR_4.VAR_5);
onCreate(VAR_3);
}
} | 0.535893 | {'IMPORT_0': 'com', 'IMPORT_1': 'movies', 'IMPORT_2': 'data', 'IMPORT_3': 'content', 'IMPORT_4': 'sqlite', 'IMPORT_5': 'SQLiteOpenHelper', 'CLASS_0': 'FavoritesDbHelper', 'CLASS_1': 'String', 'VAR_0': 'DATABASE_VERSION', 'VAR_1': 'context', 'VAR_2': 'Override', 'VAR_3': 'sqLiteDatabase', 'VAR_4': 'FavoriteEntry', 'VAR_5': 'TABLE_NAME', 'VAR_6': 'COLUMN_ORIGINAL_TITLE', 'VAR_7': 'COLUMN_POPULARITY', 'VAR_8': 'COLUMN_STORYLINE', 'VAR_9': 'COLUMN_POSTER_PATH', 'FUNC_0': 'onUpgrade', 'VAR_10': 'oldVersion', 'VAR_11': 'newVersion'} | java | Hibrido | 100.00% |
package com.logo.data.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@Table(name = "PROJECT")
@Entity
public class Project implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(name = "ID", nullable = false, updatable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private Integer id;
@Column(name = "PROJECTNR", unique = true)
@NotNull
private Integer projectNr;
@Column(name = "PROJECTNAME", nullable = false, unique = true)
@Size(min = 2, max = 50)
@NotNull
private String projectName;
@Column(name = "PROJECTDEF", nullable = false, unique = false)
@Size(min = 2, max = 100)
@NotNull
private String projectDef;
public Integer getProjectnr() {
return projectNr;
}
public void setProjectnr(Integer projectNr) {
this.projectNr = projectNr;
}
public String getProjectname() {
return projectName;
}
public void setProjectname(String projectName) {
this.projectName = projectName;
}
public String getProjectdef() {
return projectDef;
}
public void setProjectdef(String projectDef) {
this.projectDef = projectDef;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public boolean isPersisted() {
return id != null;
}
public Project() {
/* */
}
}
| package com.IMPORT_0.data.entity;
import java.IMPORT_1.Serializable;
import javax.persistence.Column;
import javax.persistence.IMPORT_2;
import javax.persistence.IMPORT_3;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.IMPORT_4.constraints.NotNull;
import javax.IMPORT_4.constraints.Size;
@Table(VAR_0 = "PROJECT")
@IMPORT_2
public class Project implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column(VAR_0 = "ID", nullable = false, VAR_1 = false)
@IMPORT_3(strategy = GenerationType.VAR_2)
private CLASS_0 id;
@Column(VAR_0 = "PROJECTNR", VAR_3 = true)
@NotNull
private CLASS_0 projectNr;
@Column(VAR_0 = "PROJECTNAME", nullable = false, VAR_3 = true)
@Size(min = 2, max = 50)
@NotNull
private String projectName;
@Column(VAR_0 = "PROJECTDEF", nullable = false, VAR_3 = false)
@Size(min = 2, max = 100)
@NotNull
private String projectDef;
public CLASS_0 getProjectnr() {
return projectNr;
}
public void setProjectnr(CLASS_0 projectNr) {
this.projectNr = projectNr;
}
public String FUNC_0() {
return projectName;
}
public void setProjectname(String projectName) {
this.projectName = projectName;
}
public String getProjectdef() {
return projectDef;
}
public void setProjectdef(String projectDef) {
this.projectDef = projectDef;
}
public CLASS_0 FUNC_1() {
return id;
}
public void setId(CLASS_0 id) {
this.id = id;
}
public boolean isPersisted() {
return id != null;
}
public Project() {
/* */
}
}
| 0.290877 | {'IMPORT_0': 'logo', 'IMPORT_1': 'io', 'IMPORT_2': 'Entity', 'IMPORT_3': 'GeneratedValue', 'IMPORT_4': 'validation', 'VAR_0': 'name', 'VAR_1': 'updatable', 'VAR_2': 'AUTO', 'CLASS_0': 'Integer', 'VAR_3': 'unique', 'FUNC_0': 'getProjectname', 'FUNC_1': 'getId'} | java | Hibrido | 100.00% |
package org.uniprot.store.datastore.member.uniref;
import static java.lang.Math.toIntExact;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import net.jodah.failsafe.RetryPolicy;
import org.uniprot.core.uniref.RepresentativeMember;
import org.uniprot.store.datastore.voldemort.member.uniref.VoldemortRemoteUniRefMemberStore;
import org.uniprot.store.job.common.store.Store;
import org.uniprot.store.job.common.writer.ItemRetryWriter;
import com.google.common.base.Strings;
/**
* @author sahmad
* @since 23/07/2020
*/
@Slf4j
public class UniRef90And50MemberRetryWriter
extends ItemRetryWriter<List<RepresentativeMember>, List<RepresentativeMember>> {
public UniRef90And50MemberRetryWriter(
Store<List<RepresentativeMember>> store, RetryPolicy<Object> retryPolicy) {
super(store, retryPolicy);
}
@Override
protected String extractItemId(List<RepresentativeMember> items) {
return items.stream()
.map(VoldemortRemoteUniRefMemberStore::getVoldemortKey)
.collect(Collectors.joining(","));
}
@Override
protected String entryToString(List<RepresentativeMember> entries) {
return entries.stream()
.map(VoldemortRemoteUniRefMemberStore::getVoldemortKey)
.collect(Collectors.joining(","));
}
@Override
public List<RepresentativeMember> itemToEntry(List<RepresentativeMember> items) {
return items;
}
@Override
protected void writeEntriesToStore(List<? extends List<RepresentativeMember>> items) {
List<List<RepresentativeMember>> convertedItems =
items.stream().map(this::itemToEntry).collect(Collectors.toList());
getStore().save(convertedItems);
int totalCount = toIntExact(convertedItems.stream().flatMap(Collection::stream).count());
getWrittenEntriesCount().addAndGet(totalCount);
recordItemsWereProcessed(totalCount);
}
@Override
protected void logFailedEntriesToFile(
List<? extends List<RepresentativeMember>> items, Throwable throwable) {
List<String> accessions = new ArrayList<>();
if (!Strings.isNullOrEmpty(getHeader())) STORE_FAILED_LOGGER.error(getHeader());
for (List<RepresentativeMember> item : items) {
String entryFF = entryToString(item);
accessions.add(extractItemId(item));
STORE_FAILED_LOGGER.error(entryFF);
}
if (!Strings.isNullOrEmpty(getFooter())) STORE_FAILED_LOGGER.error(getFooter());
log.error(ERROR_WRITING_ENTRIES_TO_STORE + accessions, throwable);
int totalCount = toIntExact(items.stream().flatMap(Collection::stream).count());
getFailedWritingEntriesCount().addAndGet(totalCount);
recordItemsWereProcessed(totalCount);
}
}
| package org.IMPORT_0.store.datastore.member.uniref;
import static java.lang.Math.IMPORT_1;
import java.IMPORT_2.IMPORT_3;
import java.IMPORT_2.Collection;
import java.IMPORT_2.List;
import java.IMPORT_2.stream.IMPORT_4;
import lombok.extern.slf4j.Slf4j;
import net.jodah.IMPORT_5.IMPORT_6;
import org.IMPORT_0.core.uniref.IMPORT_7;
import org.IMPORT_0.store.datastore.voldemort.member.uniref.VoldemortRemoteUniRefMemberStore;
import org.IMPORT_0.store.job.IMPORT_8.store.IMPORT_9;
import org.IMPORT_0.store.job.IMPORT_8.IMPORT_10.ItemRetryWriter;
import com.IMPORT_11.IMPORT_8.base.IMPORT_12;
/**
* @author sahmad
* @since 23/07/2020
*/
@Slf4j
public class CLASS_0
extends ItemRetryWriter<List<IMPORT_7>, List<IMPORT_7>> {
public CLASS_0(
IMPORT_9<List<IMPORT_7>> store, IMPORT_6<CLASS_1> retryPolicy) {
super(store, retryPolicy);
}
@VAR_0
protected String FUNC_0(List<IMPORT_7> items) {
return items.stream()
.FUNC_1(VoldemortRemoteUniRefMemberStore::VAR_1)
.FUNC_2(IMPORT_4.joining(","));
}
@VAR_0
protected String entryToString(List<IMPORT_7> VAR_2) {
return VAR_2.stream()
.FUNC_1(VoldemortRemoteUniRefMemberStore::VAR_1)
.FUNC_2(IMPORT_4.joining(","));
}
@VAR_0
public List<IMPORT_7> itemToEntry(List<IMPORT_7> items) {
return items;
}
@VAR_0
protected void FUNC_3(List<? extends List<IMPORT_7>> items) {
List<List<IMPORT_7>> convertedItems =
items.stream().FUNC_1(this::itemToEntry).FUNC_2(IMPORT_4.toList());
getStore().FUNC_4(convertedItems);
int totalCount = IMPORT_1(convertedItems.stream().flatMap(Collection::stream).FUNC_5());
FUNC_6().addAndGet(totalCount);
recordItemsWereProcessed(totalCount);
}
@VAR_0
protected void FUNC_7(
List<? extends List<IMPORT_7>> items, CLASS_2 throwable) {
List<String> accessions = new IMPORT_3<>();
if (!IMPORT_12.isNullOrEmpty(getHeader())) STORE_FAILED_LOGGER.error(getHeader());
for (List<IMPORT_7> VAR_3 : items) {
String VAR_4 = entryToString(VAR_3);
accessions.FUNC_8(FUNC_0(VAR_3));
STORE_FAILED_LOGGER.error(VAR_4);
}
if (!IMPORT_12.isNullOrEmpty(FUNC_9())) STORE_FAILED_LOGGER.error(FUNC_9());
log.error(ERROR_WRITING_ENTRIES_TO_STORE + accessions, throwable);
int totalCount = IMPORT_1(items.stream().flatMap(Collection::stream).FUNC_5());
getFailedWritingEntriesCount().addAndGet(totalCount);
recordItemsWereProcessed(totalCount);
}
}
| 0.363313 | {'IMPORT_0': 'uniprot', 'IMPORT_1': 'toIntExact', 'IMPORT_2': 'util', 'IMPORT_3': 'ArrayList', 'IMPORT_4': 'Collectors', 'IMPORT_5': 'failsafe', 'IMPORT_6': 'RetryPolicy', 'IMPORT_7': 'RepresentativeMember', 'IMPORT_8': 'common', 'IMPORT_9': 'Store', 'IMPORT_10': 'writer', 'IMPORT_11': 'google', 'IMPORT_12': 'Strings', 'CLASS_0': 'UniRef90And50MemberRetryWriter', 'CLASS_1': 'Object', 'VAR_0': 'Override', 'FUNC_0': 'extractItemId', 'FUNC_1': 'map', 'VAR_1': 'getVoldemortKey', 'FUNC_2': 'collect', 'VAR_2': 'entries', 'FUNC_3': 'writeEntriesToStore', 'FUNC_4': 'save', 'FUNC_5': 'count', 'FUNC_6': 'getWrittenEntriesCount', 'FUNC_7': 'logFailedEntriesToFile', 'CLASS_2': 'Throwable', 'VAR_3': 'item', 'VAR_4': 'entryFF', 'FUNC_8': 'add', 'FUNC_9': 'getFooter'} | java | OOP | 36.51% |
package conta.sistema.dominio.modelo;
import java.math.BigDecimal;
import static conta.sistema.dominio.modelo.Erro.obrigatario;
import static conta.sistema.dominio.modelo.Erro.saldoInsuficiente;
import static java.util.Objects.isNull;
public class Conta {
private Integer numero;
private BigDecimal saldo;
private String correntista;
public Conta() {
numero = 0;
saldo = BigDecimal.ZERO;
correntista = "não informado";
}
public Conta(Integer numero, BigDecimal saldo, String correntista) {
this.numero = numero;
this.saldo = saldo;
this.correntista = correntista;
}
public void creditar(BigDecimal credito) throws NegocioException {
if (isNull(credito)){
obrigatario("Valor crédito");
}
if (credito.compareTo(BigDecimal.ZERO) <= 0){
obrigatario("Valor crédito");
}
saldo = saldo.add(credito);
}
public void debitar(BigDecimal debito) throws NegocioException {
if (isNull(debito)){
obrigatario("Valor débito");
}
if (debito.compareTo(BigDecimal.ZERO) <= 0){
obrigatario("Valor débito");
}
if (debito.compareTo(saldo) > 0) {
saldoInsuficiente();
}
saldo = saldo.subtract(debito);
}
public Integer getNumero() {
return numero;
}
public void setNumero(Integer numero) {
this.numero = numero;
}
public BigDecimal getSaldo() {
return saldo;
}
public void setSaldo(BigDecimal saldo) {
this.saldo = saldo;
}
public String getCorrentista() {
return correntista;
}
public void setCorrentista(String correntista) {
this.correntista = correntista;
}
@Override
public String toString() {
return "Conta{" +
"numero=" + numero +
", saldo=" + saldo +
", correntista='" + correntista + '\'' +
'}';
}
}
| package conta.sistema.dominio.IMPORT_0;
import java.math.BigDecimal;
import static conta.sistema.dominio.IMPORT_0.Erro.obrigatario;
import static conta.sistema.dominio.IMPORT_0.Erro.IMPORT_1;
import static java.util.Objects.isNull;
public class Conta {
private Integer numero;
private BigDecimal saldo;
private String correntista;
public Conta() {
numero = 0;
saldo = BigDecimal.ZERO;
correntista = "não informado";
}
public Conta(Integer numero, BigDecimal saldo, String correntista) {
this.numero = numero;
this.saldo = saldo;
this.correntista = correntista;
}
public void creditar(BigDecimal credito) throws NegocioException {
if (isNull(credito)){
obrigatario("Valor crédito");
}
if (credito.FUNC_0(BigDecimal.ZERO) <= 0){
obrigatario("Valor crédito");
}
saldo = saldo.add(credito);
}
public void debitar(BigDecimal debito) throws NegocioException {
if (isNull(debito)){
obrigatario("Valor débito");
}
if (debito.FUNC_0(BigDecimal.ZERO) <= 0){
obrigatario("Valor débito");
}
if (debito.FUNC_0(saldo) > 0) {
IMPORT_1();
}
saldo = saldo.subtract(debito);
}
public Integer getNumero() {
return numero;
}
public void setNumero(Integer numero) {
this.numero = numero;
}
public BigDecimal getSaldo() {
return saldo;
}
public void setSaldo(BigDecimal saldo) {
this.saldo = saldo;
}
public String getCorrentista() {
return correntista;
}
public void setCorrentista(String correntista) {
this.correntista = correntista;
}
@Override
public String toString() {
return "Conta{" +
"numero=" + numero +
", saldo=" + saldo +
", correntista='" + correntista + '\'' +
'}';
}
}
| 0.134151 | {'IMPORT_0': 'modelo', 'IMPORT_1': 'saldoInsuficiente', 'FUNC_0': 'compareTo'} | java | error | 0 |
/**
* A wrapper for a {@link ResultSet} and a {@link RowMapper} and combines them
* in order to provide the {@link Iterator} interface.
*
* @author Thomas Krause <[email protected]>
*/
public class ResultSetTypedIterator<T> implements Iterator<T>
{
private static final Logger log = LoggerFactory.getLogger(ResultSetTypedIterator.class);
private ResultSet rs;
private RowMapper<T> mapper;
private boolean hasNext;
private int rowNum;
/**
* Constructor
* @param rs {@link ResultSet} to wrap. Must not be null.
* @param mapper Is used to map each row in each iteration step.
*/
public ResultSetTypedIterator(ResultSet rs,
RowMapper<T> mapper)
{
this.rs = rs;
this.mapper = mapper;
this.rowNum = 0;
if(rs == null)
{
throw new IllegalArgumentException("ResultSet must not be null");
}
if(mapper == null)
{
throw new IllegalArgumentException("RowMapper must not be null");
}
try
{
if(rs.getType() == ResultSet.TYPE_FORWARD_ONLY)
{
hasNext = rs.next();
}
else
{
hasNext = rs.first();
}
}
catch (SQLException ex)
{
log.error(null, ex);
}
}
/**
* Returns to the beginning of the iteration.
*/
public void reset()
{
try
{
if(rs.getType() == ResultSet.TYPE_FORWARD_ONLY)
{
throw new UnsupportedOperationException("Can not reset iterator for a ResultSet that is of type \"forward only\"");
}
hasNext = rs.first();
}
catch (SQLException ex)
{
log.error(null, ex);
}
}
@Override
public boolean hasNext()
{
return hasNext;
}
@Override
public T next()
{
if(hasNext)
{
try
{
T result = mapper.mapRow(rs, rowNum++);
// call next after the getter function to provide the item for the next call
hasNext = rs.next();
return result;
}
catch (SQLException ex)
{
log.warn("Cannot read next result set item", ex);
}
}
hasNext = false;
throw new NoSuchElementException();
}
@Override
public void remove()
{
throw new UnsupportedOperationException("Removal of items in the result set is not supported.");
}
} | /**
* A wrapper for a {@link ResultSet} and a {@link RowMapper} and combines them
* in order to provide the {@link Iterator} interface.
*
* @author Thomas Krause <[email protected]>
*/
public class CLASS_0<T> implements CLASS_1<T>
{
private static final CLASS_2 VAR_0 = LoggerFactory.FUNC_0(CLASS_0.class);
private ResultSet VAR_1;
private CLASS_3<T> mapper;
private boolean hasNext;
private int VAR_2;
/**
* Constructor
* @param rs {@link ResultSet} to wrap. Must not be null.
* @param mapper Is used to map each row in each iteration step.
*/
public CLASS_0(ResultSet VAR_1,
CLASS_3<T> mapper)
{
this.VAR_1 = VAR_1;
this.mapper = mapper;
this.VAR_2 = 0;
if(VAR_1 == null)
{
throw new CLASS_4("ResultSet must not be null");
}
if(mapper == null)
{
throw new CLASS_4("RowMapper must not be null");
}
try
{
if(VAR_1.getType() == ResultSet.VAR_3)
{
hasNext = VAR_1.FUNC_1();
}
else
{
hasNext = VAR_1.FUNC_2();
}
}
catch (SQLException VAR_4)
{
VAR_0.FUNC_3(null, VAR_4);
}
}
/**
* Returns to the beginning of the iteration.
*/
public void FUNC_4()
{
try
{
if(VAR_1.getType() == ResultSet.VAR_3)
{
throw new CLASS_5("Can not reset iterator for a ResultSet that is of type \"forward only\"");
}
hasNext = VAR_1.FUNC_2();
}
catch (SQLException VAR_4)
{
VAR_0.FUNC_3(null, VAR_4);
}
}
@Override
public boolean hasNext()
{
return hasNext;
}
@Override
public T FUNC_1()
{
if(hasNext)
{
try
{
T VAR_5 = mapper.FUNC_5(VAR_1, VAR_2++);
// call next after the getter function to provide the item for the next call
hasNext = VAR_1.FUNC_1();
return VAR_5;
}
catch (SQLException VAR_4)
{
VAR_0.FUNC_6("Cannot read next result set item", VAR_4);
}
}
hasNext = false;
throw new CLASS_6();
}
@Override
public void FUNC_7()
{
throw new CLASS_5("Removal of items in the result set is not supported.");
}
} | 0.629305 | {'CLASS_0': 'ResultSetTypedIterator', 'CLASS_1': 'Iterator', 'CLASS_2': 'Logger', 'VAR_0': 'log', 'FUNC_0': 'getLogger', 'VAR_1': 'rs', 'CLASS_3': 'RowMapper', 'VAR_2': 'rowNum', 'CLASS_4': 'IllegalArgumentException', 'VAR_3': 'TYPE_FORWARD_ONLY', 'FUNC_1': 'next', 'FUNC_2': 'first', 'VAR_4': 'ex', 'FUNC_3': 'error', 'FUNC_4': 'reset', 'CLASS_5': 'UnsupportedOperationException', 'VAR_5': 'result', 'FUNC_5': 'mapRow', 'FUNC_6': 'warn', 'CLASS_6': 'NoSuchElementException', 'FUNC_7': 'remove'} | java | Texto | 1.57% |
/**
* Create an instance of ClawPragma that correspond to a loop-fusion directive.
* Used for dynamically created transformation.
*
* @param master Base object which initiate the creation of this instance.
* @return An instance of ClawPragma describing a loop-fusion with the group,
* collapse clauses and the pragma from the master object.
*/
public static ClawPragma createLoopFusionLanguage(ClawPragma master)
{
ClawPragma l = new ClawPragma();
l.setDirective(ClawDirective.LOOP_FUSION);
if (master.hasClause(ClawClause.GROUP))
{
l.setValue(ClawClause.GROUP, master.value(ClawClause.GROUP));
}
if (master.hasClause(ClawClause.COLLAPSE))
{
l.setCollapseClause(master.getCollapseValue());
}
if (master.hasClause(ClawClause.CONSTRAINT))
{
l.setConstraintClauseValue(master.getConstraintClauseValue());
}
l.attachPragma(master.getPragma());
return l;
} | /**
* Create an instance of ClawPragma that correspond to a loop-fusion directive.
* Used for dynamically created transformation.
*
* @param master Base object which initiate the creation of this instance.
* @return An instance of ClawPragma describing a loop-fusion with the group,
* collapse clauses and the pragma from the master object.
*/
public static ClawPragma createLoopFusionLanguage(ClawPragma VAR_0)
{
ClawPragma l = new ClawPragma();
l.setDirective(ClawDirective.LOOP_FUSION);
if (VAR_0.hasClause(ClawClause.GROUP))
{
l.FUNC_0(ClawClause.GROUP, VAR_0.FUNC_1(ClawClause.GROUP));
}
if (VAR_0.hasClause(ClawClause.COLLAPSE))
{
l.FUNC_2(VAR_0.getCollapseValue());
}
if (VAR_0.hasClause(ClawClause.CONSTRAINT))
{
l.FUNC_3(VAR_0.FUNC_4());
}
l.attachPragma(VAR_0.FUNC_5());
return l;
} | 0.271401 | {'VAR_0': 'master', 'FUNC_0': 'setValue', 'FUNC_1': 'value', 'FUNC_2': 'setCollapseClause', 'FUNC_3': 'setConstraintClauseValue', 'FUNC_4': 'getConstraintClauseValue', 'FUNC_5': 'getPragma'} | java | Procedural | 52.82% |
package com.schematical.chaoscraft.ai.outputs;
import com.schematical.chaoscraft.ChaosCraft;
import com.schematical.chaoscraft.ai.OutputNeuron;
import net.minecraft.util.math.MathHelper;
/**
* Created by user1a on 12/10/18.
*/
public class ChangePitchOutput extends OutputNeuron {
@Override
public void execute() {
float delta = ((this._lastValue * 2) -1) * 90;
if(Math.abs(delta) < ChaosCraft.activationThreshold){
return;
}
//ChaosCraft.logger.info(nNet.entity.getName() + " ChangePitchOutput: " + this._lastValue + " - " + delta);
this.nNet.entity.setDesiredPitch(delta);
//this.nNet.entity.rotationPitch += delta;
}
}
| package com.schematical.chaoscraft.IMPORT_0.outputs;
import com.schematical.chaoscraft.IMPORT_1;
import com.schematical.chaoscraft.IMPORT_0.IMPORT_2;
import net.minecraft.IMPORT_3.math.MathHelper;
/**
* Created by user1a on 12/10/18.
*/
public class ChangePitchOutput extends IMPORT_2 {
@VAR_0
public void execute() {
float delta = ((this.VAR_1 * 2) -1) * 90;
if(VAR_2.abs(delta) < IMPORT_1.VAR_3){
return;
}
//ChaosCraft.logger.info(nNet.entity.getName() + " ChangePitchOutput: " + this._lastValue + " - " + delta);
this.VAR_4.VAR_5.FUNC_0(delta);
//this.nNet.entity.rotationPitch += delta;
}
}
| 0.5104 | {'IMPORT_0': 'ai', 'IMPORT_1': 'ChaosCraft', 'IMPORT_2': 'OutputNeuron', 'IMPORT_3': 'util', 'VAR_0': 'Override', 'VAR_1': '_lastValue', 'VAR_2': 'Math', 'VAR_3': 'activationThreshold', 'VAR_4': 'nNet', 'VAR_5': 'entity', 'FUNC_0': 'setDesiredPitch'} | java | OOP | 50.00% |
package com.aspose.slides.examples.charts;
import com.aspose.slides.*;
import com.aspose.slides.examples.RunExamples;
public class SetExternalWorkbook
{
public static void main(String[] args)
{
//ExStart:SetExternalWorkbook
// The path to the documents directory.
String dataDir = RunExamples.getDataDir_Charts();
Presentation pres = new Presentation();
try
{
IChart chart = pres.getSlides().get_Item(0).getShapes().addChart(ChartType.Pie, 50, 50, 400, 600, false);
IChartData chartData = chart.getChartData();
chartData.setExternalWorkbook(dataDir + "externalWorkbook.xlsx");
chartData.getSeries().add(chartData.getChartDataWorkbook().getCell(0, "B1"), ChartType.Pie);
chartData.getSeries().get_Item(0).getDataPoints().addDataPointForPieSeries(chartData.getChartDataWorkbook().getCell(0, "B2"));
chartData.getSeries().get_Item(0).getDataPoints().addDataPointForPieSeries(chartData.getChartDataWorkbook().getCell(0, "B3"));
chartData.getSeries().get_Item(0).getDataPoints().addDataPointForPieSeries(chartData.getChartDataWorkbook().getCell(0, "B4"));
chartData.getCategories().add(chartData.getChartDataWorkbook().getCell(0, "A2"));
chartData.getCategories().add(chartData.getChartDataWorkbook().getCell(0, "A3"));
chartData.getCategories().add(chartData.getChartDataWorkbook().getCell(0, "A4"));
pres.save(dataDir + "Presentation_with_externalWorkbook.pptx", SaveFormat.Pptx);
}
finally
{
if (pres != null) pres.dispose();
}
//ExEnd:SetExternalWorkbook
}
}
| package IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3.IMPORT_4;
import IMPORT_0.IMPORT_1.IMPORT_2.*;
import IMPORT_0.IMPORT_1.IMPORT_2.IMPORT_3.IMPORT_5;
public class CLASS_0
{
public static void FUNC_0(CLASS_1[] VAR_0)
{
//ExStart:SetExternalWorkbook
// The path to the documents directory.
CLASS_1 VAR_1 = IMPORT_5.FUNC_1();
CLASS_2 VAR_2 = new CLASS_2();
try
{
CLASS_3 VAR_3 = VAR_2.FUNC_2().FUNC_3(0).FUNC_4().FUNC_5(VAR_4.VAR_5, 50, 50, 400, 600, false);
CLASS_4 VAR_6 = VAR_3.FUNC_6();
VAR_6.FUNC_7(VAR_1 + "externalWorkbook.xlsx");
VAR_6.FUNC_8().FUNC_9(VAR_6.FUNC_10().FUNC_11(0, "B1"), VAR_4.VAR_5);
VAR_6.FUNC_8().FUNC_3(0).FUNC_12().FUNC_13(VAR_6.FUNC_10().FUNC_11(0, "B2"));
VAR_6.FUNC_8().FUNC_3(0).FUNC_12().FUNC_13(VAR_6.FUNC_10().FUNC_11(0, "B3"));
VAR_6.FUNC_8().FUNC_3(0).FUNC_12().FUNC_13(VAR_6.FUNC_10().FUNC_11(0, "B4"));
VAR_6.FUNC_14().FUNC_9(VAR_6.FUNC_10().FUNC_11(0, "A2"));
VAR_6.FUNC_14().FUNC_9(VAR_6.FUNC_10().FUNC_11(0, "A3"));
VAR_6.FUNC_14().FUNC_9(VAR_6.FUNC_10().FUNC_11(0, "A4"));
VAR_2.FUNC_15(VAR_1 + "Presentation_with_externalWorkbook.pptx", VAR_7.Pptx);
}
finally
{
if (VAR_2 != null) VAR_2.FUNC_16();
}
//ExEnd:SetExternalWorkbook
}
}
| 0.959652 | {'IMPORT_0': 'com', 'IMPORT_1': 'aspose', 'IMPORT_2': 'slides', 'IMPORT_3': 'examples', 'IMPORT_4': 'charts', 'IMPORT_5': 'RunExamples', 'CLASS_0': 'SetExternalWorkbook', 'FUNC_0': 'main', 'CLASS_1': 'String', 'VAR_0': 'args', 'VAR_1': 'dataDir', 'FUNC_1': 'getDataDir_Charts', 'CLASS_2': 'Presentation', 'VAR_2': 'pres', 'CLASS_3': 'IChart', 'VAR_3': 'chart', 'FUNC_2': 'getSlides', 'FUNC_3': 'get_Item', 'FUNC_4': 'getShapes', 'FUNC_5': 'addChart', 'VAR_4': 'ChartType', 'VAR_5': 'Pie', 'CLASS_4': 'IChartData', 'VAR_6': 'chartData', 'FUNC_6': 'getChartData', 'FUNC_7': 'setExternalWorkbook', 'FUNC_8': 'getSeries', 'FUNC_9': 'add', 'FUNC_10': 'getChartDataWorkbook', 'FUNC_11': 'getCell', 'FUNC_12': 'getDataPoints', 'FUNC_13': 'addDataPointForPieSeries', 'FUNC_14': 'getCategories', 'FUNC_15': 'save', 'VAR_7': 'SaveFormat', 'FUNC_16': 'dispose'} | java | OOP | 40.09% |
/**
* Check that indirection won't cause us to write outside the
* malloc'ed space.
*/
protected void boundsCheck(long off, long sz) {
if (off < 0) {
throw new IndexOutOfBoundsException("Invalid offset: " + off);
}
if (off + sz > bytesAvailable) {
String msg = "Bounds exceeds available space : size="
+ bytesAvailable + ", offset=" + (off + sz);
throw new IndexOutOfBoundsException(msg);
}
} | /**
* Check that indirection won't cause us to write outside the
* malloc'ed space.
*/
protected void boundsCheck(long off, long VAR_0) {
if (off < 0) {
throw new IndexOutOfBoundsException("Invalid offset: " + off);
}
if (off + VAR_0 > bytesAvailable) {
String msg = "Bounds exceeds available space : size="
+ bytesAvailable + ", offset=" + (off + VAR_0);
throw new IndexOutOfBoundsException(msg);
}
} | 0.071561 | {'VAR_0': 'sz'} | java | Procedural | 100.00% |
package me.ddozzi.allowhubs.listener;
import me.ddozzi.allowhubs.DungeonHub;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StringUtils;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class ChatListener {
public static Minecraft mc = Minecraft.getMinecraft();
@SubscribeEvent(receiveCanceled = true, priority = EventPriority.LOW )
public void onChat(ClientChatReceivedEvent event) {
String unformatted = StringUtils.stripControlCodes(event.message.getUnformattedText());
if (unformatted.startsWith(" ☠ You were ")) {
if (DungeonHub.config.autowarp == true) {
Utils.checkForDungeons();
Utils.checkForSkyblock();
if (Utils.isOnHypixel() && Utils.inSkyblock && Utils.inDungeons) {
new Thread(() -> {
try {
String option = new String("");
if (DungeonHub.config.warpchoice == 0) {
option = "hub";
} else if (DungeonHub.config.warpchoice == 1) {
option = "dungeon_hub";
} else if (DungeonHub.config.warpchoice == 2) {
option = "home";
} else if (DungeonHub.config.warpchoice > 2) {
System.out.println("error, out of bounds contact ddozzi");
}
Thread.sleep(DungeonHub.config.autowarpdelay);
Minecraft.getMinecraft().thePlayer.sendChatMessage("/l");
Thread.sleep(DungeonHub.config.delay);
Minecraft.getMinecraft().thePlayer.sendChatMessage("/skyblock");
Thread.sleep(DungeonHub.config.delay);
Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp "+ option);
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
}
} else {
return;
}
}
}}
| package me.ddozzi.allowhubs.listener;
import me.ddozzi.allowhubs.DungeonHub;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.ChatStyle;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.StringUtils;
import net.minecraftforge.client.event.ClientChatReceivedEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
public class ChatListener {
public static Minecraft mc = Minecraft.getMinecraft();
@SubscribeEvent(receiveCanceled = true, priority = EventPriority.LOW )
public void onChat(ClientChatReceivedEvent event) {
String unformatted = StringUtils.stripControlCodes(event.message.getUnformattedText());
if (unformatted.startsWith(" ☠ You were ")) {
if (DungeonHub.config.autowarp == true) {
Utils.checkForDungeons();
Utils.checkForSkyblock();
if (Utils.isOnHypixel() && Utils.inSkyblock && Utils.inDungeons) {
new Thread(() -> {
try {
String VAR_0 = new String("");
if (DungeonHub.config.warpchoice == 0) {
VAR_0 = "hub";
} else if (DungeonHub.config.warpchoice == 1) {
VAR_0 = "dungeon_hub";
} else if (DungeonHub.config.warpchoice == 2) {
VAR_0 = "home";
} else if (DungeonHub.config.warpchoice > 2) {
System.out.println("error, out of bounds contact ddozzi");
}
Thread.sleep(DungeonHub.config.autowarpdelay);
Minecraft.getMinecraft().thePlayer.sendChatMessage("/l");
Thread.sleep(DungeonHub.config.delay);
Minecraft.getMinecraft().thePlayer.sendChatMessage("/skyblock");
Thread.sleep(DungeonHub.config.delay);
Minecraft.getMinecraft().thePlayer.sendChatMessage("/warp "+ VAR_0);
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
}
} else {
return;
}
}
}}
| 0.031266 | {'VAR_0': 'option'} | java | OOP | 82.35% |
/*******************************************************************************
* 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.storm.eventhubs.spout;
import com.microsoft.azure.eventhubs.EventData;
import org.apache.storm.tuple.Fields;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* An Event Data Scheme which deserializes message payload into the Strings. No
* encoding is assumed. The receiver will need to handle parsing of the string
* data in appropriate encoding.
*
* The resulting tuple would contain two items: the the message string, and a
* map of properties that include metadata, which can be used to determine who
* processes the message, and how it is processed.
*
* For passing the raw bytes of a messsage to Bolts, refer to
* {@link BinaryEventDataScheme}.
*/
public class EventDataScheme implements IEventDataScheme {
private static final long serialVersionUID = 1L;
private static final Logger logger = LoggerFactory.getLogger(EventDataScheme.class);
@Override
public List<Object> deserialize(EventData eventData) {
final List<Object> fieldContents = new ArrayList<Object>();
String messageData = "";
if (eventData.getBytes()!=null) {
messageData = new String(eventData.getBytes());
}
/*Will only serialize AMQPValue type*/
else if (eventData.getObject()!=null) {
try {
if (!(eventData.getObject() instanceof List)) {
messageData = eventData.getObject().toString();
} else {
throw new RuntimeException("Cannot serialize the given AMQP type");
}
} catch (RuntimeException e) {
logger.error("Failed to serialize EventData payload class"
+ eventData.getObject().getClass());
logger.error("Exception encountered while serializing EventData payload is"
+ e.toString());
throw e;
}
}
Map<String, Object> metaDataMap = eventData.getProperties();
fieldContents.add(messageData);
fieldContents.add(metaDataMap);
return fieldContents;
}
@Override
public Fields getOutputFields() {
return new Fields(FieldConstants.Message, FieldConstants.META_DATA);
}
}
| /*******************************************************************************
* 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 IMPORT_0.IMPORT_1.storm.eventhubs.spout;
import IMPORT_2.microsoft.azure.eventhubs.EventData;
import IMPORT_0.IMPORT_1.storm.IMPORT_3.Fields;
import IMPORT_0.slf4j.IMPORT_4;
import IMPORT_0.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.IMPORT_5;
/**
* An Event Data Scheme which deserializes message payload into the Strings. No
* encoding is assumed. The receiver will need to handle parsing of the string
* data in appropriate encoding.
*
* The resulting tuple would contain two items: the the message string, and a
* map of properties that include metadata, which can be used to determine who
* processes the message, and how it is processed.
*
* For passing the raw bytes of a messsage to Bolts, refer to
* {@link BinaryEventDataScheme}.
*/
public class CLASS_0 implements IEventDataScheme {
private static final long serialVersionUID = 1L;
private static final IMPORT_4 VAR_0 = LoggerFactory.FUNC_0(CLASS_0.class);
@VAR_1
public List<Object> FUNC_1(EventData eventData) {
final List<Object> VAR_2 = new ArrayList<Object>();
String messageData = "";
if (eventData.getBytes()!=null) {
messageData = new String(eventData.getBytes());
}
/*Will only serialize AMQPValue type*/
else if (eventData.getObject()!=null) {
try {
if (!(eventData.getObject() instanceof List)) {
messageData = eventData.getObject().toString();
} else {
throw new CLASS_1("Cannot serialize the given AMQP type");
}
} catch (CLASS_1 e) {
VAR_0.error("Failed to serialize EventData payload class"
+ eventData.getObject().getClass());
VAR_0.error("Exception encountered while serializing EventData payload is"
+ e.toString());
throw e;
}
}
IMPORT_5<String, Object> metaDataMap = eventData.getProperties();
VAR_2.add(messageData);
VAR_2.add(metaDataMap);
return VAR_2;
}
@VAR_1
public Fields getOutputFields() {
return new Fields(FieldConstants.Message, FieldConstants.VAR_3);
}
}
| 0.269779 | {'IMPORT_0': 'org', 'IMPORT_1': 'apache', 'IMPORT_2': 'com', 'IMPORT_3': 'tuple', 'IMPORT_4': 'Logger', 'IMPORT_5': 'Map', 'CLASS_0': 'EventDataScheme', 'VAR_0': 'logger', 'FUNC_0': 'getLogger', 'VAR_1': 'Override', 'FUNC_1': 'deserialize', 'VAR_2': 'fieldContents', 'CLASS_1': 'RuntimeException', 'VAR_3': 'META_DATA'} | java | Procedural | 56.07% |
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import static java.util.stream.Collectors.toList;
public class Item8_4 {
public static void main(String... args) {
List<Usuario> usuarios = new ArrayList<>();
usuarios.add(new Usuario("itanor", 30));
usuarios.add(new Usuario("pedro", 240));
usuarios.add(new Usuario("jose", 520));
usuarios.add(new Usuario("maria", 100));
// executar uma tarefa toda vez que processa um elemento...
// 'findAny', 'collect' e 'forEach' são operações terminais...
usuarios.stream()
.filter(u -> u.getPontos() > 100)
.peek(System.out::println)
.findAny();
// 'sorted' é uma operação intermediária stateful
usuarios.stream()
.sorted(Comparator.comparing(Usuario::getNome))
.peek(System.out::println)
.findAny();
}
}
| import java.IMPORT_0.IMPORT_1;
import java.IMPORT_0.IMPORT_2;
import java.IMPORT_0.Comparator;
import static java.IMPORT_0.IMPORT_3.IMPORT_4.IMPORT_5;
public class CLASS_0 {
public static void FUNC_0(CLASS_1... VAR_0) {
IMPORT_1<CLASS_2> VAR_2 = new IMPORT_2<>();
VAR_2.FUNC_1(new CLASS_2("itanor", 30));
VAR_2.FUNC_1(new CLASS_2("pedro", 240));
VAR_2.FUNC_1(new CLASS_2("jose", 520));
VAR_2.FUNC_1(new CLASS_2("maria", 100));
// executar uma tarefa toda vez que processa um elemento...
// 'findAny', 'collect' e 'forEach' são operações terminais...
VAR_2.IMPORT_3()
.FUNC_2(VAR_3 -> VAR_3.FUNC_3() > 100)
.FUNC_4(System.VAR_4::VAR_5)
.FUNC_5();
// 'sorted' é uma operação intermediária stateful
VAR_2.IMPORT_3()
.FUNC_6(Comparator.FUNC_7(VAR_1::VAR_6))
.FUNC_4(System.VAR_4::VAR_5)
.FUNC_5();
}
}
| 0.772792 | {'IMPORT_0': 'util', 'IMPORT_1': 'List', 'IMPORT_2': 'ArrayList', 'IMPORT_3': 'stream', 'IMPORT_4': 'Collectors', 'IMPORT_5': 'toList', 'CLASS_0': 'Item8_4', 'FUNC_0': 'main', 'CLASS_1': 'String', 'VAR_0': 'args', 'CLASS_2': 'Usuario', 'VAR_1': 'Usuario', 'VAR_2': 'usuarios', 'FUNC_1': 'add', 'FUNC_2': 'filter', 'VAR_3': 'u', 'FUNC_3': 'getPontos', 'FUNC_4': 'peek', 'VAR_4': 'out', 'VAR_5': 'println', 'FUNC_5': 'findAny', 'FUNC_6': 'sorted', 'FUNC_7': 'comparing', 'VAR_6': 'getNome'} | java | OOP | 31.91% |
/**
* Tests whether the specified name is a valid accessibility profile
* property name (eg. "high-contrast" or "large-fonts").
*/
public static boolean isAccessibilityPropertyName(String name)
{
return (XMLConstants.ACC_HIGH_CONTRAST.equals(name) ||
XMLConstants.ACC_LARGE_FONTS.equals(name));
} | /**
* Tests whether the specified name is a valid accessibility profile
* property name (eg. "high-contrast" or "large-fonts").
*/
public static boolean isAccessibilityPropertyName(CLASS_0 name)
{
return (VAR_0.ACC_HIGH_CONTRAST.equals(name) ||
VAR_0.ACC_LARGE_FONTS.equals(name));
} | 0.182887 | {'CLASS_0': 'String', 'VAR_0': 'XMLConstants'} | java | Procedural | 75.61% |
/**
* Created by Mklaus on 15/4/23.
*/
public class RefundQuery extends WxpayRequestBase {
//KEY
public static final String URL_API_BASE = "https://api.mch.weixin.qq.com/pay/refundquery";
public static final String KEY_OUT_TRADE_NO = "out_trade_no";
public static final String KEY_OUT_REFUND_NO = "out_refund_no";
public static final String KEY_REFUND_ID = "refund_id";
public static final String KEY_TRANSACTION_ID = "transaction_id";
public static final List<String> KEYS_PARAM_NAME = Arrays.asList(
"appid",
"device_info",
"mch_id",
"nonce_str",
"out_refund_no",
"out_trade_no",
"refund_id",
"sign",
"transaction_id"
);
// CONSTRUCT
public RefundQuery(Properties prop)
{
super(prop);
return;
}
// BUILD
@Override
public RefundQuery build()
{
return (this);
}
// SIGN
@Override
public RefundQuery sign() throws UnsupportedEncodingException
{
super.sign(KEYS_PARAM_NAME);
return (this);
}
// EXECUTE
@Override
public RefundQueryResponse execute()
throws WxpayException, WxpayProtocolException, IOException
{
String url = URL_API_BASE;
String body = super.buildXMLBody(KEYS_PARAM_NAME);
InputStream respXml = super.executePostXML(url, body);
return(new RefundQueryResponse(respXml));
}
// TO_URL
public String toURL()
throws UnsupportedOperationException
{
throw(
new UnsupportedOperationException("This request does not execute on client side.")
);
}
// PROPERTY
/** 商户系统内部的订单号
*/
public RefundQuery setOutTradeNo(String outTradeNo)
{
super.setProperty(KEY_OUT_TRADE_NO,outTradeNo);
return (this);
}
/** 微信订单号
*/
public RefundQuery setTransactionId(String transactionId)
{
super.setProperty(KEY_TRANSACTION_ID,transactionId);
return (this);
}
/** 商户退款单号
*/
public RefundQuery setOutRefundNo(String outRefundNo)
{
super.setProperty(KEY_OUT_REFUND_NO,outRefundNo);
return (this);
}
/** 微信退款单号
* refund_id、out_refund_no、out_trade_no、transaction_id 四个参数必填一个,如果同事存在优先级为:
* refund_id>out_refund_no>transaction_id>out_trade_no
*/
public RefundQuery setRefundId(String refundId)
{
super.setProperty(KEY_REFUND_ID,refundId);
return (this);
}
} | /**
* Created by Mklaus on 15/4/23.
*/
public class RefundQuery extends WxpayRequestBase {
//KEY
public static final String URL_API_BASE = "https://api.mch.weixin.qq.com/pay/refundquery";
public static final String VAR_0 = "out_trade_no";
public static final String KEY_OUT_REFUND_NO = "out_refund_no";
public static final String KEY_REFUND_ID = "refund_id";
public static final String KEY_TRANSACTION_ID = "transaction_id";
public static final List<String> KEYS_PARAM_NAME = Arrays.FUNC_0(
"appid",
"device_info",
"mch_id",
"nonce_str",
"out_refund_no",
"out_trade_no",
"refund_id",
"sign",
"transaction_id"
);
// CONSTRUCT
public RefundQuery(Properties prop)
{
super(prop);
return;
}
// BUILD
@Override
public RefundQuery build()
{
return (this);
}
// SIGN
@Override
public RefundQuery sign() throws UnsupportedEncodingException
{
super.sign(KEYS_PARAM_NAME);
return (this);
}
// EXECUTE
@Override
public RefundQueryResponse execute()
throws WxpayException, WxpayProtocolException, IOException
{
String url = URL_API_BASE;
String body = super.buildXMLBody(KEYS_PARAM_NAME);
InputStream VAR_1 = super.executePostXML(url, body);
return(new RefundQueryResponse(VAR_1));
}
// TO_URL
public String FUNC_1()
throws CLASS_0
{
throw(
new CLASS_0("This request does not execute on client side.")
);
}
// PROPERTY
/** 商户系统内部的订单号
*/
public RefundQuery FUNC_2(String outTradeNo)
{
super.setProperty(VAR_0,outTradeNo);
return (this);
}
/** 微信订单号
*/
public RefundQuery FUNC_3(String transactionId)
{
super.setProperty(KEY_TRANSACTION_ID,transactionId);
return (this);
}
/** 商户退款单号
*/
public RefundQuery setOutRefundNo(String outRefundNo)
{
super.setProperty(KEY_OUT_REFUND_NO,outRefundNo);
return (this);
}
/** 微信退款单号
* refund_id、out_refund_no、out_trade_no、transaction_id 四个参数必填一个,如果同事存在优先级为:
* refund_id>out_refund_no>transaction_id>out_trade_no
*/
public RefundQuery setRefundId(String refundId)
{
super.setProperty(KEY_REFUND_ID,refundId);
return (this);
}
} | 0.186893 | {'VAR_0': 'KEY_OUT_TRADE_NO', 'FUNC_0': 'asList', 'VAR_1': 'respXml', 'FUNC_1': 'toURL', 'CLASS_0': 'UnsupportedOperationException', 'FUNC_2': 'setOutTradeNo', 'FUNC_3': 'setTransactionId'} | java | OOP | 54.47% |
package relational;
import java.io.FileInputStream;
import java.sql.*;
import java.util.Properties;
import java.util.ArrayList;
import domain.Predicate;
public class DBConnection {
public String cacheDbName;
public String outputDbName;
Properties dbProperties;
enum SQLVariant {MySQL, SQLServer, Oracle}
SQLVariant dbVendor;
Connection con;
Statement stmt;
ResultSet rs;
public DBConnection(String filename) {
try {
// load the database connection properties from a file
FileInputStream in = new FileInputStream(filename);
dbProperties = new Properties();
dbProperties.load(in);
in.close();
cacheDbName = dbProperties.getProperty("cacheDbName");
outputDbName = dbProperties.getProperty("outputDbName");
String jdbcDriver = dbProperties.getProperty("jdbcDriver");
// record type of database:
if (jdbcDriver.equals("com.mysql.jdbc.Driver")) {
dbVendor = SQLVariant.MySQL;
}
else if (jdbcDriver.equals("com.microsoft.jdbc.sqlserver.SQLServerDriver")) {
dbVendor = SQLVariant.SQLServer;
}
// start database connection ....
Class.forName(jdbcDriver);
con = DriverManager.getConnection(dbProperties.getProperty("dbURL"),dbProperties.getProperty("dbUser"),dbProperties.getProperty("dbPassword"));
stmt = con.createStatement();
}
catch (Exception e) {
e.printStackTrace();
System.exit(9);
}
createDatabaseIfNotExists(cacheDbName);
createDatabaseIfNotExists(outputDbName);
}
public DBConnection(String jdbcDriver, String dbURL, String dbUser, String dbPassword) {
try {
// record type of database:
if (jdbcDriver.equals("com.mysql.jdbc.Driver")) {
dbVendor = SQLVariant.MySQL;
}
else if (jdbcDriver.equals("com.microsoft.jdbc.sqlserver.SQLServerDriver")) {
dbVendor = SQLVariant.SQLServer;
}
// start database connection ....
Class.forName(jdbcDriver);
con = DriverManager.getConnection(dbURL,dbUser,dbPassword);
stmt = con.createStatement();
}
catch (Exception e) {
e.printStackTrace();
System.exit(9);
}
}
public void close() {
try {
stmt.close();
con.close();
}
catch (Exception e) {
e.printStackTrace();
System.exit(9);
}
}
public void resetTables(String dbName, ArrayList<Predicate> preds) {
for (Predicate p: preds) {
resetTable(dbName,p);
}
}
public void resetTable(String dbName, Predicate pred) {
// drop tables for predicate
dropTable(dbName+"."+pred.dbTable);
dropTable(dbName+".InvocationsOf_" + pred.dbTable);
// create new table for predicate:
ArrayList<String> columns = new ArrayList<String>(pred.arity);
for (int j=0; j<pred.arity; j++) {
columns.add(pred.types[j].name + j + " " + pred.types[j].primitiveType);
}
createTable(dbName+"."+pred.dbTable,columns);
// create also InvocationsOf table containing only input parameters
columns = new ArrayList<String>();
for (int j=0; j<pred.arity; j++) {
if (pred.bindings[j]) {
columns.add(pred.types[j].name + j + " " + pred.types[j].primitiveType);
}
}
if (!columns.isEmpty()) {
createTable(dbName+"."+"InvocationsOf_" + pred.dbTable, columns);
}
}
public boolean createTable(String name, ArrayList<String> columns) {
String update = null;
try {
update = "CREATE TABLE " + name + " ( " + commaSeparated(columns) + " )";
stmt.executeUpdate(update);
System.out.println(update);
}
catch (Exception e) {
System.err.println("Error in DBConnection.createTable(): update = "+update );
e.printStackTrace();
return false;
}
return true; // success
}
public boolean createDatabaseIfNotExists(String name) {
String update = null;
try {
update = "CREATE DATABASE IF NOT EXISTS `" + name + "`;";
stmt.executeUpdate(update);
System.out.println(update);
}
catch (Exception e) {
System.err.println("Error in DBConnection.createDatabaseIfNotExists(): update = "+update );
e.printStackTrace();
return false;
}
return true; // success
}
public boolean createTableIfNotExists(String name, String[] columns, String primaryKey) {
String update = null;
try {
update = "CREATE TABLE IF NOT EXISTS " + name + " ( " + commaSeparated(columns);
if (primaryKey != null) {
update += ", PRIMARY KEY ("+primaryKey+")";
}
update += " )";
stmt.executeUpdate(update);
System.out.println(update);
}
catch (Exception e) {
System.err.println("Error in DBConnection.createTableIfNotExists(): update = "+update );
e.printStackTrace();
return false;
}
return true; // success
}
public boolean dropTable(String name) {
String update = null;
try {
// drop database tables
update = "DROP TABLE IF EXISTS " + name;
stmt.executeUpdate(update);
System.out.println(update);
}
catch (Exception e) {
System.err.println("Error in DBConnection.dropTable(): update = "+update );
e.printStackTrace();
return false;
}
return true; // success
}
public Table runQuery(String query) {
Table table = null;
try {
// execute query
rs = stmt.executeQuery(query);
// get metadata
ResultSetMetaData md = rs.getMetaData();
int columnCount = md.getColumnCount();
ArrayList<String> columnNames = new ArrayList<String>(columnCount);
for (int i=0; i<columnCount; i++) {
columnNames.add(md.getColumnName(i+1));
}
table = new Table(columnNames);
// get data
while (rs.next()) {
ArrayList<String> tuple = new ArrayList<String>(columnCount);
for (int i=0; i<columnCount; i++) {
tuple.add(rs.getString(i+1));
}
table.insertDistinct(tuple);
}
}
catch (Exception e) {
System.err.println("query = "+query);
e.printStackTrace();
System.exit(9);
}
return table;
}
public void insert(String table, ArrayList<String> tuple) {
// insert tuple into database
String update = null;
try {
update = "INSERT INTO " + table + " VALUES (";
for (int i=0; i<tuple.size(); i++) {
if (i!=0) { update += ","; }
String val = tuple.get(i);
if (val == null) {
val = "";
}
else {
val = val.trim();
}
update += "\"" + val.replaceAll("\"","\\\\\"") + "\"";
}
update += ")";
stmt.executeUpdate(update);
}
catch (Exception e) {
System.err.println("update = " + update);
e.printStackTrace();
}
}
public void insert(String table, String[] tuple) {
ArrayList<String> t = new ArrayList<String>();
for (String val: tuple) { t.add(val); }
insert(table, t);
}
public boolean returnsEmptySet(String query) {
try {
// execute query
return !stmt.executeQuery(query).next();
}
catch (Exception e) {
System.err.println("query = "+query);
e.printStackTrace();
System.exit(9);
}
return true;
}
public int count(String table) {
return firstIntValue("SELECT COUNT(*) FROM " + table);
}
public int countDistinct(String table, String column) {
return firstIntValue("SELECT COUNT(DISTINCT " + column + ") FROM " + table);
}
public int countDistinct(String table, ArrayList<String> columns) {
return firstIntValue("SELECT COUNT(DISTINCT " + commaSeparated(columns) + ") FROM " + table);
}
public Table randomSubset(String table, int count, boolean distinct) {
return runQuery(randomSubsetSQL(table,null,count,distinct));
}
public Table randomSubset(String table, ArrayList<String> columns, int count, boolean distinct) {
return runQuery(randomSubsetSQL(table,commaSeparated(columns),count,distinct));
}
public ArrayList<String> randomSubset(String table, String column, int count, boolean distinct) {
return runQuery(randomSubsetSQL(table,column,count,distinct)).getColumnValues(0);
}
/////////////////////////////////////////////////////
// static methods
public static void testConnection(String filename) {
DBConnection u = new DBConnection(filename);
System.out.println("Successful creation of DB connection.");
u.close();
}
/////////////////////////////////////////////////////
// private methods
private int firstIntValue(String query) {
int value = 0;
try {
rs = stmt.executeQuery(query);
if (rs.next()) {
value = rs.getInt(1);
}
}
catch (Exception e) {
System.err.println("query = " + query);
e.printStackTrace();
System.exit(9);
}
return value;
}
private String randomSubsetSQL(String table, String attributes, int sampleSize, boolean distinct) {
if (attributes == null) {
attributes = "*";
}
String modifier = "";
if (distinct) {
modifier = "DISTINCT ";
}
switch (dbVendor) {
case MySQL:
return "SELECT " + modifier + attributes + " FROM " + table + " ORDER BY RAND() LIMIT " + sampleSize;
case SQLServer:
return "SELECT TOP " + sampleSize + " " + modifier + attributes + " FROM " + table + " ORDER BY NEWID()";
case Oracle:
System.err.println("Error in DBConnection.randomSubsetQuery(): method is NOT YET IMPLEMENTED for ORACLE db!!!");
System.exit(9);
}
return null;
}
private String commaSeparated(String[] list) {
String s = "";
for (String l: list) { s += l+",";}
return s.substring(0,s.length()-1);
}
private String commaSeparated(ArrayList<String> list) {
String s = "";
for (String l: list) { s += l+",";}
return s.substring(0,s.length()-1);
}
}
| package relational;
import java.io.FileInputStream;
import java.IMPORT_0.*;
import java.util.IMPORT_1;
import java.util.IMPORT_2;
import domain.Predicate;
public class CLASS_0 {
public String VAR_0;
public String VAR_1;
IMPORT_1 dbProperties;
enum CLASS_1 {VAR_3, SQLServer, VAR_4}
CLASS_1 dbVendor;
CLASS_2 con;
Statement stmt;
ResultSet rs;
public CLASS_0(String filename) {
try {
// load the database connection properties from a file
FileInputStream VAR_5 = new FileInputStream(filename);
dbProperties = new IMPORT_1();
dbProperties.load(VAR_5);
VAR_5.FUNC_0();
VAR_0 = dbProperties.getProperty("cacheDbName");
VAR_1 = dbProperties.getProperty("outputDbName");
String VAR_6 = dbProperties.getProperty("jdbcDriver");
// record type of database:
if (VAR_6.equals("com.mysql.jdbc.Driver")) {
dbVendor = VAR_2.VAR_3;
}
else if (VAR_6.equals("com.microsoft.jdbc.sqlserver.SQLServerDriver")) {
dbVendor = VAR_2.SQLServer;
}
// start database connection ....
Class.FUNC_1(VAR_6);
con = DriverManager.getConnection(dbProperties.getProperty("dbURL"),dbProperties.getProperty("dbUser"),dbProperties.getProperty("dbPassword"));
stmt = con.FUNC_2();
}
catch (Exception e) {
e.printStackTrace();
System.FUNC_3(9);
}
createDatabaseIfNotExists(VAR_0);
createDatabaseIfNotExists(VAR_1);
}
public CLASS_0(String VAR_6, String dbURL, String dbUser, String VAR_7) {
try {
// record type of database:
if (VAR_6.equals("com.mysql.jdbc.Driver")) {
dbVendor = VAR_2.VAR_3;
}
else if (VAR_6.equals("com.microsoft.jdbc.sqlserver.SQLServerDriver")) {
dbVendor = VAR_2.SQLServer;
}
// start database connection ....
Class.FUNC_1(VAR_6);
con = DriverManager.getConnection(dbURL,dbUser,VAR_7);
stmt = con.FUNC_2();
}
catch (Exception e) {
e.printStackTrace();
System.FUNC_3(9);
}
}
public void FUNC_0() {
try {
stmt.FUNC_0();
con.FUNC_0();
}
catch (Exception e) {
e.printStackTrace();
System.FUNC_3(9);
}
}
public void FUNC_4(String dbName, IMPORT_2<Predicate> preds) {
for (Predicate p: preds) {
FUNC_5(dbName,p);
}
}
public void FUNC_5(String dbName, Predicate pred) {
// drop tables for predicate
dropTable(dbName+"."+pred.VAR_8);
dropTable(dbName+".InvocationsOf_" + pred.VAR_8);
// create new table for predicate:
IMPORT_2<String> columns = new IMPORT_2<String>(pred.arity);
for (int VAR_9=0; VAR_9<pred.arity; VAR_9++) {
columns.FUNC_6(pred.types[VAR_9].name + VAR_9 + " " + pred.types[VAR_9].VAR_10);
}
createTable(dbName+"."+pred.VAR_8,columns);
// create also InvocationsOf table containing only input parameters
columns = new IMPORT_2<String>();
for (int VAR_9=0; VAR_9<pred.arity; VAR_9++) {
if (pred.bindings[VAR_9]) {
columns.FUNC_6(pred.types[VAR_9].name + VAR_9 + " " + pred.types[VAR_9].VAR_10);
}
}
if (!columns.isEmpty()) {
createTable(dbName+"."+"InvocationsOf_" + pred.VAR_8, columns);
}
}
public boolean createTable(String name, IMPORT_2<String> columns) {
String update = null;
try {
update = "CREATE TABLE " + name + " ( " + commaSeparated(columns) + " )";
stmt.FUNC_7(update);
System.out.println(update);
}
catch (Exception e) {
System.err.println("Error in DBConnection.createTable(): update = "+update );
e.printStackTrace();
return false;
}
return true; // success
}
public boolean createDatabaseIfNotExists(String name) {
String update = null;
try {
update = "CREATE DATABASE IF NOT EXISTS `" + name + "`;";
stmt.FUNC_7(update);
System.out.println(update);
}
catch (Exception e) {
System.err.println("Error in DBConnection.createDatabaseIfNotExists(): update = "+update );
e.printStackTrace();
return false;
}
return true; // success
}
public boolean createTableIfNotExists(String name, String[] columns, String primaryKey) {
String update = null;
try {
update = "CREATE TABLE IF NOT EXISTS " + name + " ( " + commaSeparated(columns);
if (primaryKey != null) {
update += ", PRIMARY KEY ("+primaryKey+")";
}
update += " )";
stmt.FUNC_7(update);
System.out.println(update);
}
catch (Exception e) {
System.err.println("Error in DBConnection.createTableIfNotExists(): update = "+update );
e.printStackTrace();
return false;
}
return true; // success
}
public boolean dropTable(String name) {
String update = null;
try {
// drop database tables
update = "DROP TABLE IF EXISTS " + name;
stmt.FUNC_7(update);
System.out.println(update);
}
catch (Exception e) {
System.err.println("Error in DBConnection.dropTable(): update = "+update );
e.printStackTrace();
return false;
}
return true; // success
}
public Table runQuery(String query) {
Table table = null;
try {
// execute query
rs = stmt.FUNC_8(query);
// get metadata
ResultSetMetaData md = rs.getMetaData();
int columnCount = md.FUNC_9();
IMPORT_2<String> columnNames = new IMPORT_2<String>(columnCount);
for (int VAR_11=0; VAR_11<columnCount; VAR_11++) {
columnNames.FUNC_6(md.getColumnName(VAR_11+1));
}
table = new Table(columnNames);
// get data
while (rs.FUNC_10()) {
IMPORT_2<String> VAR_12 = new IMPORT_2<String>(columnCount);
for (int VAR_11=0; VAR_11<columnCount; VAR_11++) {
VAR_12.FUNC_6(rs.getString(VAR_11+1));
}
table.FUNC_11(VAR_12);
}
}
catch (Exception e) {
System.err.println("query = "+query);
e.printStackTrace();
System.FUNC_3(9);
}
return table;
}
public void insert(String table, IMPORT_2<String> VAR_12) {
// insert tuple into database
String update = null;
try {
update = "INSERT INTO " + table + " VALUES (";
for (int VAR_11=0; VAR_11<VAR_12.FUNC_12(); VAR_11++) {
if (VAR_11!=0) { update += ","; }
String val = VAR_12.get(VAR_11);
if (val == null) {
val = "";
}
else {
val = val.trim();
}
update += "\"" + val.replaceAll("\"","\\\\\"") + "\"";
}
update += ")";
stmt.FUNC_7(update);
}
catch (Exception e) {
System.err.println("update = " + update);
e.printStackTrace();
}
}
public void insert(String table, String[] VAR_12) {
IMPORT_2<String> t = new IMPORT_2<String>();
for (String val: VAR_12) { t.FUNC_6(val); }
insert(table, t);
}
public boolean returnsEmptySet(String query) {
try {
// execute query
return !stmt.FUNC_8(query).FUNC_10();
}
catch (Exception e) {
System.err.println("query = "+query);
e.printStackTrace();
System.FUNC_3(9);
}
return true;
}
public int count(String table) {
return firstIntValue("SELECT COUNT(*) FROM " + table);
}
public int countDistinct(String table, String column) {
return firstIntValue("SELECT COUNT(DISTINCT " + column + ") FROM " + table);
}
public int countDistinct(String table, IMPORT_2<String> columns) {
return firstIntValue("SELECT COUNT(DISTINCT " + commaSeparated(columns) + ") FROM " + table);
}
public Table randomSubset(String table, int count, boolean distinct) {
return runQuery(randomSubsetSQL(table,null,count,distinct));
}
public Table randomSubset(String table, IMPORT_2<String> columns, int count, boolean distinct) {
return runQuery(randomSubsetSQL(table,commaSeparated(columns),count,distinct));
}
public IMPORT_2<String> randomSubset(String table, String column, int count, boolean distinct) {
return runQuery(randomSubsetSQL(table,column,count,distinct)).getColumnValues(0);
}
/////////////////////////////////////////////////////
// static methods
public static void testConnection(String filename) {
CLASS_0 u = new CLASS_0(filename);
System.out.println("Successful creation of DB connection.");
u.FUNC_0();
}
/////////////////////////////////////////////////////
// private methods
private int firstIntValue(String query) {
int VAR_13 = 0;
try {
rs = stmt.FUNC_8(query);
if (rs.FUNC_10()) {
VAR_13 = rs.getInt(1);
}
}
catch (Exception e) {
System.err.println("query = " + query);
e.printStackTrace();
System.FUNC_3(9);
}
return VAR_13;
}
private String randomSubsetSQL(String table, String attributes, int sampleSize, boolean distinct) {
if (attributes == null) {
attributes = "*";
}
String modifier = "";
if (distinct) {
modifier = "DISTINCT ";
}
switch (dbVendor) {
case VAR_3:
return "SELECT " + modifier + attributes + " FROM " + table + " ORDER BY RAND() LIMIT " + sampleSize;
case SQLServer:
return "SELECT TOP " + sampleSize + " " + modifier + attributes + " FROM " + table + " ORDER BY NEWID()";
case VAR_4:
System.err.println("Error in DBConnection.randomSubsetQuery(): method is NOT YET IMPLEMENTED for ORACLE db!!!");
System.FUNC_3(9);
}
return null;
}
private String commaSeparated(String[] VAR_14) {
String VAR_15 = "";
for (String VAR_16: VAR_14) { VAR_15 += VAR_16+",";}
return VAR_15.substring(0,VAR_15.length()-1);
}
private String commaSeparated(IMPORT_2<String> VAR_14) {
String VAR_15 = "";
for (String VAR_16: VAR_14) { VAR_15 += VAR_16+",";}
return VAR_15.substring(0,VAR_15.length()-1);
}
}
| 0.306235 | {'IMPORT_0': 'sql', 'IMPORT_1': 'Properties', 'IMPORT_2': 'ArrayList', 'CLASS_0': 'DBConnection', 'VAR_0': 'cacheDbName', 'VAR_1': 'outputDbName', 'CLASS_1': 'SQLVariant', 'VAR_2': 'SQLVariant', 'VAR_3': 'MySQL', 'VAR_4': 'Oracle', 'CLASS_2': 'Connection', 'VAR_5': 'in', 'FUNC_0': 'close', 'VAR_6': 'jdbcDriver', 'FUNC_1': 'forName', 'FUNC_2': 'createStatement', 'FUNC_3': 'exit', 'VAR_7': 'dbPassword', 'FUNC_4': 'resetTables', 'FUNC_5': 'resetTable', 'VAR_8': 'dbTable', 'VAR_9': 'j', 'FUNC_6': 'add', 'VAR_10': 'primitiveType', 'FUNC_7': 'executeUpdate', 'FUNC_8': 'executeQuery', 'FUNC_9': 'getColumnCount', 'VAR_11': 'i', 'FUNC_10': 'next', 'VAR_12': 'tuple', 'FUNC_11': 'insertDistinct', 'FUNC_12': 'size', 'VAR_13': 'value', 'VAR_14': 'list', 'VAR_15': 's', 'VAR_16': 'l'} | java | error | 0 |
package org.stagemonitor.alerting.alerter;
import java.io.IOException;
import java.util.Collections;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.stagemonitor.alerting.AlertingPlugin;
import org.stagemonitor.core.MeasurementSession;
import org.stagemonitor.core.Stagemonitor;
import org.stagemonitor.core.util.JsonUtils;
public class AlerterTypeServlet extends HttpServlet {
private final AlertingPlugin alertingPlugin;
private final MeasurementSession measurementSession;
public AlerterTypeServlet() {
this(Stagemonitor.getConfiguration(AlertingPlugin.class), Stagemonitor.getMeasurementSession());
}
public AlerterTypeServlet(AlertingPlugin alertingPlugin, MeasurementSession measurementSession) {
this.alertingPlugin = alertingPlugin;
this.measurementSession = measurementSession;
}
/**
* Returns all available alerters
*/
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
if (alertingPlugin.getAlertSender() != null) {
JsonUtils.writeJsonToOutputStream(alertingPlugin.getAlertSender().getAvailableAlerters(),
resp.getOutputStream());
} else {
JsonUtils.writeJsonToOutputStream(Collections.emptyList(), resp.getOutputStream());
}
}
@Override
protected long getLastModified(HttpServletRequest req) {
return measurementSession.getStartTimestamp();
}
}
| package IMPORT_0.stagemonitor.IMPORT_1.IMPORT_2;
import IMPORT_3.IMPORT_4.IMPORT_5;
import IMPORT_3.util.Collections;
import IMPORT_6.IMPORT_7.IMPORT_8;
import IMPORT_6.IMPORT_7.http.HttpServlet;
import IMPORT_6.IMPORT_7.http.HttpServletRequest;
import IMPORT_6.IMPORT_7.http.IMPORT_9;
import IMPORT_0.stagemonitor.IMPORT_1.AlertingPlugin;
import IMPORT_0.stagemonitor.IMPORT_10.IMPORT_11;
import IMPORT_0.stagemonitor.IMPORT_10.Stagemonitor;
import IMPORT_0.stagemonitor.IMPORT_10.util.IMPORT_12;
public class AlerterTypeServlet extends HttpServlet {
private final AlertingPlugin alertingPlugin;
private final IMPORT_11 VAR_0;
public AlerterTypeServlet() {
this(Stagemonitor.getConfiguration(AlertingPlugin.class), Stagemonitor.FUNC_0());
}
public AlerterTypeServlet(AlertingPlugin alertingPlugin, IMPORT_11 VAR_0) {
this.alertingPlugin = alertingPlugin;
this.VAR_0 = VAR_0;
}
/**
* Returns all available alerters
*/
@VAR_1
protected void doGet(HttpServletRequest VAR_2, IMPORT_9 resp) throws IMPORT_8, IMPORT_5 {
if (alertingPlugin.FUNC_1() != null) {
IMPORT_12.writeJsonToOutputStream(alertingPlugin.FUNC_1().FUNC_2(),
resp.getOutputStream());
} else {
IMPORT_12.writeJsonToOutputStream(Collections.emptyList(), resp.getOutputStream());
}
}
@VAR_1
protected long FUNC_3(HttpServletRequest VAR_2) {
return VAR_0.getStartTimestamp();
}
}
| 0.616636 | {'IMPORT_0': 'org', 'IMPORT_1': 'alerting', 'IMPORT_2': 'alerter', 'IMPORT_3': 'java', 'IMPORT_4': 'io', 'IMPORT_5': 'IOException', 'IMPORT_6': 'javax', 'IMPORT_7': 'servlet', 'IMPORT_8': 'ServletException', 'IMPORT_9': 'HttpServletResponse', 'IMPORT_10': 'core', 'IMPORT_11': 'MeasurementSession', 'IMPORT_12': 'JsonUtils', 'VAR_0': 'measurementSession', 'FUNC_0': 'getMeasurementSession', 'VAR_1': 'Override', 'VAR_2': 'req', 'FUNC_1': 'getAlertSender', 'FUNC_2': 'getAvailableAlerters', 'FUNC_3': 'getLastModified'} | java | OOP | 43.50% |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.