method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
16119b3c-cd98-46bf-a9f5-5fbedba69151 | 3 | public void addEffectToGrid(Effect effect) {
if (effect == null)
throw new IllegalArgumentException("Effect can't be null!");
if (effects.contains(effect))
throw new IllegalArgumentException("The argument is already on the grid!");
if (!validPosition(effect.getPosition()))
throw new IllegalArgumentExcept... |
6e9a50ea-ed4f-4dd3-ace3-f7d952ea5054 | 2 | private int modifyFile(BufferedWriter out, Object fileToModify, int fileSize, int... bytesStart) throws IOException {
int dataModified = 0;
ArrayList<ByteRange> ranges = new ArrayList<ByteRange>();
for (int byteStart : bytesStart) {
// int byteStart = this.getRealisticByteModification(fileSize);
int byteE... |
9bfe3d57-0579-4b77-92fc-92deef1e4239 | 1 | @Override
public int getHeight() {
int height = 0;
if (this.fontmetrics != null) {
height = this.fontmetrics.getHeight();
}
return height;
} |
72de6b7d-98c3-4fbe-b8d2-9c857105c3a8 | 3 | public static boolean isOwner(final CommandSender sender, final Region region) {
if (sender.hasPermission("simpleregions.override.commands")) return true;
if ((sender instanceof Player) && region.owners.inherits(sender)) return true;
return false;
} |
74c98d66-3346-4667-bbb9-c7801f64016c | 4 | @Override
protected void updateComponent(long currentTime) {
Card thisTopPlayCard = Game.linkedGet().getPlayPile().peek();
ArrayList<Card> thisCurrentHand = (Game.linkedGet().getCurrentPlayer() == null) ? null : (ArrayList<Card>) Game.linkedGet().getCurrentPlayer().getCards().clone();
if ((... |
23e76b5c-a2e7-46b5-846a-6b0f99397e7c | 2 | public Color getCityColor(Fraktion f) {
if (f == Fraktion.Blau) {
return blau;
} else if (f == Fraktion.Rot) {
return rot;
}
return neutralColor;
} |
53095e21-a86b-4648-968f-d30e361b0138 | 6 | public void cargarEstudianteActualizar(int cedula) {
String sql = "select * from actualizar(" + cedula + ")";
try {
conexion.consultar(sql);
while (conexion.getRes().next()) {
this.setNombre(conexion.getRes().getString(1));
this.setApellido(conexio... |
2ed0a35c-3b08-4d36-91ca-3e858b23758c | 1 | public String toString() {
StringBuilder sb = new StringBuilder();
for (Vehicle v: this.getCars()) {
sb.append(v.toString());
}
return "Road(" + this.hashCode() + "): " + sb.toString();
} |
ae2adbc5-a466-4946-b14e-1f5a6d1aa468 | 0 | @XmlElementDecl(namespace = "http://www.rsasecurity.com/rsalabs/pkcs/schemas/pkcs-5v2-0#", name = "PBKDF2-params")
public JAXBElement<PBKDF2ParameterType> createPBKDF2Params(PBKDF2ParameterType value) {
return new JAXBElement<PBKDF2ParameterType>(_PBKDF2Params_QNAME, PBKDF2ParameterType.class, null, value);... |
a2115621-73f7-4e0b-81e4-a4c5b1dfefb1 | 5 | public String[] setTribeNames(String tribeOne, String tribeTwo){
// temp tribe vars.
String oldT1 = tribeNames[0];
String oldT2 = tribeNames[1];
// set the new tribes (Contestant requires this)
tribeNames[0] = Utils.strCapitalize(tribeOne.toLowerCase().trim());
tribeNames[1] = Utils.strCapitalize(tribeTwo.t... |
a819ce44-e640-4628-8b97-0fd072bcf3e8 | 4 | public int getTurnCount() {
boolean test = false;
if (test || m_test) {
System.out.println("Game :: getTurnCount() BEGIN");
}
if (test || m_test) {
System.out.println("Game :: getTurnCount() END");
}
return m_turnCount;
} |
c00f362a-3c24-4510-b86e-f7a0760ab648 | 6 | private void acceptNewClient()
{
System.out.println("Waiting for a new client");
(new Thread()
{
@Override
public void run()
{
try
{
Client c = new Client(server.accept());
clients.add(c);
System.out.println("Client " + c + " accepted");
System.out.println(clients.size() +... |
6c3b1c6d-1d01-4b3c-9ea8-a9f42f656bed | 2 | public static void main(String[] args) throws Exception
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
ArrayList<String> words = new ArrayList<String>();
for (int i = 0; i < 20; i++)
{
words.add(reader.readLine());
}
Map<... |
74bc5f87-1194-4593-9fd2-caa773545a22 | 2 | @Override
protected Transferable createTransferable(JComponent c) {
Transferable t = null;
if (c instanceof JList) {
@SuppressWarnings("unchecked")
JList<RosterComponent> list = (JList<RosterComponent>) c;
Object value = new RosterTransferComponent(list.getSelectedValue());
... |
5d7f6fa1-fdd3-4284-b043-96141af8b76d | 9 | @Override
public boolean equals(Object o)
{
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Player player = (Player) o;
if (power != player.power) return false;
if (size != player.size) return false;
if (name != null ? !nam... |
6f5aa130-29f3-4c40-a2c4-483d0172cc8d | 4 | public void Compute(HashMap<Integer, Integer> events){
m_coordinates.setX(m_coordinates.getX() + Math.round(m_velocity.X()));
m_coordinates.setY(m_coordinates.getY() + Math.round(m_velocity.Y()));
if((m_coordinates.getX() < 0 ) || (m_coordinates.getX() > Physics.MAX_X) || (m_coordinates.getY() ... |
49cf9b5e-6ba9-4023-bba2-f6842b69d01a | 2 | public static String getWord() {
skipWhitespace();
StringBuffer str = new StringBuffer(50);
char ch = lookChar();
while (ch == EOF || !Character.isWhitespace(ch)) {
str.append(readChar());
ch = lookChar();
}
return str.toString();
} |
d5c769ee-abb7-49e8-ad87-acc0adc856cf | 4 | public String formatPlayTimeLeft(Player p, int min, int sec){
if(p.hasPermission(DeityNether.OVERRIDE_PERMISSION)){
return cu.format(lang.getString("nether.time.play.override").replaceAll("%header", getHeader()));
}else if(p.hasPermission(DeityNether.GENERAL_PERMISSION)){
String m = "";
String s = "";
i... |
d236c3de-2fa5-41b3-86d0-eb20b2aa019a | 2 | @Override
public int compareTo(LabelGeneOverlap o) {
double difference = o.overlapArea-overlapArea;
if(difference==0){
return 0;
}
if(difference<0){
return -1;
}
return 1;
} |
3e687a02-ab44-4fe3-8c8b-4b006cb0e32e | 7 | private static List<String> makePluginNameList(final Map<?, ?> map,
final String key) throws InvalidDescriptionException {
final Object value = map.get(key);
if (value == null) {
return new GapList<>();
}
final GapList<String> pluginNameList = new GapList<>();
try {
for (final Object entry : (Iterabl... |
e4488431-5005-42d1-9ae1-a41a6e3cbfee | 4 | public boolean equals(Vector4f v) {
if (this.x == v.getX() && this.y == v.getY() && this.z == v.getZ() && this.w == v.getW())
return true;
return false;
} |
e97db7a5-fc4c-427f-91ec-cf0eb30277dd | 4 | public void triggerEvent(final DTimer event) {
List<DTimerListener> eventListeners = this.listeners.get(event
.getEventName());
if (eventListeners == null || eventListeners.size() == 0) {
// debug no list
}
for (final DTimerListener listener : eventListeners) ... |
a76bb9d1-d92b-4498-8e02-39d5e5c76629 | 0 | public void setFooArray(T[] fooArray)
{
this.fooArray = fooArray;
} |
35266647-25d8-4fb6-9ed9-a2aa3bea5e01 | 7 | public JComponent getGui() {
if (gui==null) {
Map<Key, Object> hintsMap = new HashMap<RenderingHints.Key,Object>();
hintsMap.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
hintsMap.put(RenderingHints.KEY_DITHERING, RenderingHints.VALUE_DITHER_ENABLE);... |
54475c16-724b-4af9-8928-feb9de0d03e1 | 7 | boolean isLegalCharacter(char c)
{
// CheckStyle:MagicNumber OFF
if (c == 0x9 || c == 0xA || c == 0xD)
{
return true;
}
else if (c < 0x20)
{
return false;
}
else if (c <= 0xD7FF)
{
return true;
}
else if (c < 0xE000)
{
return false;
}
else if (c <= 0xFFFD)
{
return true;
... |
da9d303b-29e1-4746-ac78-02352b65119e | 4 | public void generate(String year, String title, ArrayList<String> authors,
ArrayList<String> categories, String shortDescription,
String dpublic, String age, ArrayList<String> notes, String gamePlay,
String gameRules) {
Element xmlRoot = new Element("infos");
Element ... |
c77cc17d-a012-4387-8adb-36a1d5ece5e1 | 8 | public boolean similar(Object other) {
if (!(other instanceof JSONArray)) {
return false;
}
int len = this.length();
if (len != ((JSONArray)other).length()) {
return false;
}
for (int i = 0; i < len; i += 1) {
Object valueThis = this.ge... |
a0117eb3-474d-44d1-b556-d8d751733978 | 9 | private float[][][] cuboidResponse(List<IplImage> gaussianList, double omega)
{
if(gaussianList == null || gaussianList.size() == 0)
{
return null;
}
IplImage firstIamge = gaussianList.get(0);
int width = firstIamge.width();
int height = firstIamge.height();
int length = gaussianList.size();
floa... |
c4ef899c-89e5-42ca-b8ce-f46086e562af | 1 | public V getFinalValue() {
if (isSetValue()) { return value; }
return defaultValue;
} |
a220677b-d12f-4e64-93ec-c0d72a17bbd8 | 7 | public static ListNode removeDuplicatesSolutionTwo(ListNode head) {
if (head == null || head.next == null) {
return head;
}
/* PHASE #1: Count number of appearances for each element */
Map<Integer, Integer> counts = new HashMap<Integer, Integer>();
ListNode ptr = head;
while (ptr != null) {
... |
57872b4b-cb89-4ba3-9dbb-61d1ba4c0dbd | 1 | @Override
protected void onKick(String channel, String kickerNick, String kickerLogin, String kickerHostname, String recipientNick, String reason) {
if ( recipientNick.equals( getNick() ) ) {
joinChannel(channel);
sendMessage(channel, kickerNick + ": polib si elipsy");
}
... |
1600b996-6b97-4fe1-be14-bd8123d72a5a | 2 | public static int getIntValue(String value) {
if(value != null) {
try {
return Integer.parseInt(value);
} catch(NumberFormatException exception) {}
}
throw new IllegalArgumentException("Invalid value");
} |
88eb46f4-844a-4bf2-9ef8-5c19f2cd479d | 0 | public Rectangle getFirstCorner() {
return firstCorner;
} |
8c378a53-d099-431b-83af-48d78712ca6d | 3 | public static Timestamp getDatahMaxPesquisa() throws SQLException, ClassNotFoundException {
ResultSet rs;
Timestamp z = null;
Connection conPol = conMgr.getConnection("PD");
if (conPol == null) {
throw new SQLException("Numero Maximo de Conexoes Atingida!");
}
... |
e6cde612-5ce8-4060-aa36-df90a3efcb41 | 7 | @SuppressWarnings("deprecation")
public static void main(String[] args)
{
//declare variables
//tracks number of incorrect answers
int failures=0;
//number of allowed failures
int numOfFailures=7;
//temp word, will come from a file or database in the end
String word="Love";
StringBuilder visible... |
bcc52cb5-3171-415c-b7a7-f302d4d9f387 | 9 | private void showTip() {
String text = null;
tooltipowner = null;
String classname = getClass(mouseinside);
if ((classname == "tabbedpane") || (classname == "menubar") || (classname == ":popup")) {
if (insidepart != null) {
text = getString(insidepart, "tooltip", null);
}
}
else if (classname == "... |
e2d13980-18d6-4e02-bf45-7cf3f54837ea | 3 | @Override
public synchronized void send(String s) throws RemoteException {
ClientService chatClient = null;
for(String username : chatClients){
try {
chatClient = (ClientService) Naming.lookup(username);
chatClient.send(s);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (NotB... |
9c4f3815-9c10-442e-b59e-71aa73766e04 | 6 | @Override
public void onKeyDown(char key, int keyCode, boolean coded)
{
if (coded)
{
// Turns with left / right arrowkey
if (keyCode == KeyEvent.VK_LEFT)
{
//System.out.println(calculateTurning());
turn(calculateTurning());
}
else if (keyCode == KeyEvent.VK_RIGHT)
turn(-calculateTurning... |
b5061f14-8aec-48fa-87e5-b2b9ec5d869c | 7 | public static double evaluateAveragePrecision( HashMap<String, HashMap<Integer,Double>> relevance_judgments,
String path){
double value = 0.0;
double AP = 0.0;
int RR = 0;
int i=0;
try {
BufferedReader reader = new Bu... |
88e8f40f-53bf-4f68-a2e9-db880b0c8b14 | 5 | public void setAttackValue(int x, int y, int value, String player)
{
WorldChunk chunk = getChunkAt(x,y, false);
if(chunk == null)
return;
if(this.worldType == WorldType.CLIENT && !handlingChanges)
{
// if(NettyClientHandler.current != null)
// ... |
92655fe7-cee5-4102-ac63-2a4e21b94548 | 6 | private static Map<String, String> loadSeedProducts(String seedFileName) throws Exception {
int totalRows = 0, badUPCCount = 0, badProductIdCount = 0;
Map<String, String> products = new LinkedHashMap<String, String>();
XSSFWorkbook wb = readFile(seedFileName);
for (int k = 0; k < 1; k++) {
XSSFSheet sheet... |
c0c8e48f-bdf1-460a-8d58-f562fb2361e5 | 6 | @Override
/**
* Returns true if managed to find a free square adjacent to target, and teleport there.
* False if none found.
*/
public boolean execute(Entity actor, Entity target, Parameters context) {
if(!(actor instanceof game.objects.Unit)){
throw new IllegalStateException("TeleportToTarget effect is o... |
0c89cb1e-eaf9-411a-a713-53be0e941d55 | 1 | public JMenu getMnChat() {
if (mnChat == null) {
mnChat = new JMenu("Chat");
mnChat.add(getMntmConectar());
mnChat.add(getMntmDesconectar());
mnChat.add(getMntmSalir());
}
return mnChat;
} |
5b734521-3736-48a6-8433-e24d78f9bb6c | 2 | @Override
protected void onComplete() {
if (!cancelled) {
if (soundAtEnd != null)
soundAtEnd.play();
//end.setResource(transform);
panel.remove(moving);
}
} |
bb6e61ef-e7e7-433d-b72e-f38d81230631 | 5 | @Override
public void run() {
int i = 0;
try {
listenerSocket = new ServerSocket(port);
Socket socket;
EIError.debugMsg("Listening");
gameController.showMessage("Success", "Waiting for incoming connection...");
gameController.multiplayer... |
808b0422-491d-4f02-8702-2acc64cc6751 | 2 | public boolean contains(Object li) {
li = ((LocalInfo) li).getLocalInfo();
for (int i = 0; i < count; i++)
if (locals[i].getLocalInfo() == li)
return true;
return false;
} |
763a6758-1cf1-4dd3-8723-114f23c9e698 | 1 | public int destroy(int idCrlv) throws ClassNotFoundException, ClassNotFoundException, SQLException{
int result;
con = abrirBanco(con);
PreparedStatement stm;
String sql = "delete from ipva where crlv_id_crlv = ?";
stm = con.prepareStatement(sql);
stm.setInt(1, idCrlv);
... |
8a8197ba-8743-4c5e-90b2-eb15332e7858 | 9 | public byte getPositionCode(int x, int y) {
if (rectNW.contains(x, y))
return NW;
if (rectN.contains(x, y))
return NORTH;
if (rectNE.contains(x, y))
return NE;
if (rectE.contains(x, y))
return EAST;
if (rectSE.contains(x, y))
return SE;
if (rectS.contains(x, y))
return SOUTH;
if (rectSW.... |
629babcd-8714-4438-a7b7-0ebb1b3c2eac | 4 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (!(obj instanceof MyNode))
return false;
MyNode other = (MyNode) obj;
if (id != other.id)
return false;
return... |
a76a1f9e-6220-492a-b2c2-5a5af0a221fd | 9 | private void setKey(byte[] key)
{
int[] k32e = new int[MAX_KEY_BITS/64]; // 4
int[] k32o = new int[MAX_KEY_BITS/64]; // 4
int[] sBoxKeys = new int[MAX_KEY_BITS/64]; // 4
gSubKeys = new int[TOTAL_SUBKEYS];
if (k64Cnt < 1)
{
throw new IllegalArgumentExc... |
7b5e5baa-8073-4f92-9735-ed2d8e093151 | 1 | @Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
} |
b67950c1-678e-47b9-ae84-cedadfa15ca7 | 4 | private void procServerMap(Packet p) {
PacketReader pr = p.getByteBufferReader();
switch (MapPacketType.valueOf(pr.readUint8())) {
case MAP_PACKET_START:
long frameCounter = pr.readUint32();
this.expectedSaveLength = (int) pr.readUint32();
break;
case MAP_PACKET_NORMAL:
this.saveGameData = A... |
6dfe724b-21e5-4818-a589-373669eac73a | 4 | @Override
public void run() {
try {
socket = new Socket("localhost", 7000);
} catch (UnknownHostException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
System.out.println(new Date() + " --> Connected to server at "
+ socket.getLocalAddress() + ":" + socket.getL... |
5d8b279c-0bd1-4f9b-81e7-2f2dd05469ce | 6 | private Object[] getDecodedStreamBytesAndSize(int presize) {
InputStream input = getInputStreamForDecodedStreamBytes();
if (input == null)
return null;
try {
int outLength;
if (presize > 0)
outLength = presize;
else
... |
56313360-5e9d-44ef-8901-0ec2b9c17483 | 5 | public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
Type type = typeToken.getType();
Class<? super T> rawType = typeToken.getRawType();
if (!Map.class.isAssignableFrom(rawType)) {
return null;
}
Class<?> rawTypeOfSrc = $Gson$Types.getRawType(type);
Type[] keyAndValueTyp... |
9acdd981-1ea0-4b6c-9813-1b737d685eeb | 4 | public static int firstIndexOfNonWhiteSpace( String string )
{
if ( isEmpty( string ) ) {
return 0;
}
int left = 0;
for ( char eachChar : string.toCharArray() ) {
if ( eachChar != ' ' && eachChar != '\t' ) {
break;
}
lef... |
036247ad-07c6-4d41-9f6d-7923328d2d12 | 4 | public static void main(String[] args) {
// TODO Auto-generated method stub
//func = ScoreFunctionFactory.getScoreFunction("KLSum+");
Document.initialize(Document.ParseMode.POS);
String fname = "Sentiment";
String docset = ".Crawler";
if (ROOTDIR.equals("/home/graveendran/Downloads/DUC")) {
docset = ".DU... |
54c73a7b-1e55-4bad-bda2-b36c755058c1 | 5 | public void AddGlobalObj(int objectX, int objectY, int NewObjectID, int Face, int ObjectType) {
for (Player p : server.playerHandler.players)
{
if(p != null)
{
client person = (client)p;
if((person.playerName != null || person.playerName != "null")... |
f28c30bc-d9c2-4a45-bdba-dd978f66c44f | 5 | public Item addItemInList(ItemDTO dto) {
Item itemList = null;
if (dto.getDtoMap().get(Constants.TYPE)
.equalsIgnoreCase(Constants.RAW_ITEM)) {
itemList = new RawItem();
} else if (dto.getDtoMap().get(Constants.TYPE)
.equalsIgnoreCase(Constants.MANUFACTURED_ITEM)) {
itemList = new ManufacturedItem(... |
9e6778dd-66c5-4031-8c8b-b7919975b902 | 4 | @SuppressWarnings("unchecked")
public String getEventAveragesTable() {
PreparedStatement st = null;
ResultSet rs = null;
JSONArray json = new JSONArray();
try {
conn = dbconn.getConnection();
st = conn.prepareStatement("SELECT m.event_id, e.name, avg(m.auton_t... |
93cf381f-4f7d-4b6c-98aa-b82091a22359 | 4 | public FlacAudioFrame getNextAudioPacket() throws IOException {
int skipped = 0;
int b1 = 0;
int b2 = input.read();
while (b1 != -1 && b2 != -1) {
b1 = b2;
b2 = input.read();
if (FlacAudioFrame.isFrameHeaderStart(b1, b2)) {
if (skipped > 0)
... |
13672f53-8b96-45fd-986b-fa5605a7dad1 | 2 | public void pesquisaTurma(String disc, int num) {
try {
Disciplina dis = sistemaFrontEnd.pesquisaDisciplina(disc);
try {
JOptionPane.showMessageDialog(null,
sistemaFrontEnd.pesquisaTurma(disc, num));
} catch (TurmaInexistenteException e) {
front.exibirMsg("Turma Inexistente!!");
}
} catch... |
77dc845d-729a-465b-aa29-d49634a8fb7e | 2 | public TitleScreen(int frameWidth, int frameHeight)
{
try
{
image = ImageIO.read(new File("logo.png"));
}
catch (IOException ex)
{
System.out.println("Can't read image.");
}
this.frameWidth = frameWidth;
... |
c37ce990-5f9e-462c-a567-8ff80ad94063 | 9 | private void evaluateInput(String message) throws Exception {
// Parse the input message
Matcher matcher = pattern.matcher(message);
if (matcher.matches() == false) {
throw new IllegalArgumentException(
"Syntax error: " + message);
}
... |
2861e7a8-1298-45cf-a6c2-8b44d2cac70f | 8 | private Map<Good, HashMap<Enums.MarketValues, Integer>> filterGoods(Map<Good, HashMap<Enums.MarketValues, Integer>> candidateValues, RandomPort port){ //}, RandomPort port){
Set<Good> keys = new HashSet<Good>();
for (Good good : candidateValues.keySet()){
if (filterIfPreAgriculture(port, goo... |
e7ce33ee-58d5-4f03-8562-624909719110 | 7 | public boolean start() {
synchronized (optOutLock) {
// Did we opt out?
if (isOptOut()) {
return false;
}
// Is metrics already running?
if (task != null) {
return true;
}
// Begin hitting the s... |
63c2dc1b-7316-4436-a6f5-7c6fe164cad1 | 8 | public static boolean computeCell(boolean[][] world, int col, int row)
{
// liveCell is true if the cell at position (col,row) in world is live
boolean liveCell = getCell(world, col, row);
// neighbours is the number of live neighbours to cell (col,row)
int neighbours = countNeighbours(world, col... |
d2d878e2-c9f1-40e6-8052-43e58c40198f | 4 | @Test
public void test_addition() {
int m = 2;
int n = 3;
Matrix m1 = new MatrixArrayList(m, n);
Matrix m2 = new MatrixArrayList(m, n);
Matrix m3 = new MatrixArrayList(m, n);
for (int i = 1; i <= m; i++) {
for (int j = 1; j <= n; j++)
m1.insert(i, j, (double) (2 * i + j));
}
for (int i = 1; i ... |
6b981390-1f8d-4b98-bcce-4e884a0ad01b | 8 | public static File getFile(int column)
{
switch (column) {
case 1: return File.a;
case 2: return File.b;
case 3: return File.c;
case 4: return File.d;
case 5: return File.e;
case 6: return File.f;
case 7: return File.g;
case 8: return File.h;
... |
c5ae06a6-ca4f-4f5d-bc9c-e27b56c80b81 | 4 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (!(obj instanceof BaggageCarriage))
return false;
BaggageCarriage other = (BaggageCarriage) obj;
if (shelfCount != other.shelfCount)
return false;
return true;
} |
5717030f-3e4e-45a7-912c-beef19394661 | 2 | private void lockedAndPreventingPlayerUse(JButton button, boolean trueOrFalse) {
if(!areWeUnlocked) {
setUpButtonImage(button, lockImage, 100, 50);
areWeUnlocked = true;
}
else if(areWeUnlocked) {
setUpButtonImage(button, unlockImage, 100, 50);
are... |
4b73464a-1426-477d-9d60-a912371f34f7 | 5 | private static BigInteger mp(BigInteger base,BigInteger exponent,BigInteger modulus) {
BigInteger result=BigInteger.ONE; // initialize variable
// failsafe
if( base.compareTo(BigInteger.ONE) < 0 || exponent.compareTo(BigInteger.ZERO) < 0 || modulus.compareTo(BigInteger.ONE) < 1) {
return BigInteger... |
c791a864-5166-483b-ad81-cb538f832c3b | 9 | public void initProvider(String initialContextFactory, String jndiProviderUrl, Map<String, String> settings) throws Exception {
Properties env = new Properties( );
env.put(Context.INITIAL_CONTEXT_FACTORY, initialContextFactory);
env.put(Context.PROVIDER_URL, jndiProviderUrl);
initialContext = new InitialContext... |
a4538ff6-9d56-4669-9551-abdd942d61dc | 6 | public boolean onCommand(CommandSender cs, Command cmnd, String string, String[] args) {
if (args.length == 0) {
if (cs instanceof Player) {
args = new String[]{cs.getName()};
} else {
cs.sendMessage(ChatColor.RED + "Invalid usage: " + getHelp());
... |
170d3b9a-cf66-4f0d-9d82-4d24134f5cc4 | 3 | private void drawConnectors(Graphics2D g) {
for (Connector c : connectors) {
Color cSave = g.getColor();
Stroke sSave = g.getStroke();
if (c.isSelected()) {
g.setColor(Color.red);
g.setStroke(new BasicStroke(2f));
}
if (c instanceof InputConnector) {
drawInput(g, (InputConnector) c);
} e... |
39387cde-54cd-4b98-af56-2a8b3db19def | 8 | public void swapView(String name)
{
myLayout.show(getContentPane(), name);
if(name.equals("The Game"))
{
if(mainGame.volumeOn)
{
//sequencer.stop();
try
{
sequencer.setSequence(SORAIRO_DAYS);
}
catc... |
7578e853-681d-44dd-a069-98a37f654b40 | 1 | public static void main(String[] args) throws InterruptedException {
Callable<Integer> callable = new CallableImpl(2);
ExecutorService executor = new ScheduledThreadPoolExecutor(1);
Future<Integer> future = executor.submit(callable);
try {
System.out.println("Future value: ... |
c9d6f82d-a2eb-4f6e-a427-f8a671bb6e23 | 5 | public int[] getRowColBounds()
{
/* KSC: try to decrease processing time by using refPtgs treemap
int[] retValues = {0,0,0,0};
for (int i=0;i<sqrefs.size();i++) {
SqRef sref = (SqRef)sqrefs.get(i);
int[] locs = sref.getIntLocation();
for (int x=0;x<2... |
c91454b6-5bd3-40bf-8482-598c32dacca8 | 8 | public boolean submitClaim(Claim c, String actionType) {
boolean flag = false;
Element claimE = (Element) document
.selectSingleNode("//" + actionType + "[@id='" + c.getId() + "']");
if (claimE != null) {
claimE.element("dialogState").setText(c.getDialogState());
// Write to xml
try {
XmlUtils.wr... |
a091eb90-93c7-4431-8458-36059d11c352 | 7 | public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
boolean retry;
Boolean b = (Boolean) context.getAttribute(ExecutionContext.HTTP_REQ_SENT);
boolean sent = (b != null && b.booleanValue());
if(executionCount > maxRetries) {
// Do n... |
7e0fe9a0-743f-4e66-84f6-ca9e588484d6 | 9 | public int strStr(String haystack, String needle) {
if (haystack == null || needle == null || haystack.length() < needle.length()) {
return -1;
}
if (needle.length() == 0) {
return 0;
}
int limit = Math.min(needle.length(), haystack.length() - needle.lengt... |
90aaa547-bd62-465d-b294-25dd9c984976 | 6 | static private Token jj_consume_token(int kind) throws ParseException {
Token oldToken;
if ((oldToken = token).next != null) token = token.next;
else token = token.next = token_source.getNextToken();
jj_ntk = -1;
if (token.kind == kind) {
jj_gen++;
if (++jj_gc > 100) {
jj_gc = 0;... |
0ded67f7-239f-4874-b6cd-5f16f61957f7 | 8 | @Override
public synchronized void close() throws IOException {
if(!this.closed) {
LOG.info("closing a file");
if(this.keepaliveThread != null && this.keepaliveThread.isAlive()) {
this.keepaliveThread.interrupt();
}
this.keepaliveT... |
bf1ff143-a055-40da-a648-af8b8853d625 | 5 | public JSONObject increment(String key) throws JSONException {
Object value = opt(key);
if (value == null) {
put(key, 1);
} else if (value instanceof Integer) {
put(key, ((Integer) value).intValue() + 1);
} else if (value instanceof Long) {
put(key, ((... |
05507d22-d418-4c57-a665-6a2a0e44f562 | 0 | public String toString() {
return this.getName();
} |
3dded4b2-320d-4f89-9182-2f0f77f6d09d | 1 | public void close() throws IOException {
while (numBitsInCurrentByte != 0)
write((byte)0);
output.close();
} |
e81f0047-ba25-4182-a662-d56cb5fbab41 | 8 | public static ArrayList<Node> getNodes(SQLiteConnection db) {
ArrayList<Node> nodes = new ArrayList<>();
try{
SQLiteStatement st = db.prepare("SELECT * FROM node");
while (st.step()){
Node nod = new Node(db, st.columnInt(1),
new Point(st.c... |
1bea7f65-0ed1-4d82-ba80-aa18c90d6861 | 0 | protected Spielgrenze(Rectangle masse, IntHolder unit) {
super(masse, unit);
} |
58eed814-18fd-4b39-b9b2-73ac4fcffb34 | 8 | private void shutdown() {
try {
isRunning = false;
FileWriter fileWriter = new FileWriter(FileCreator.getStreamListFile());
ArrayList<String> streamList = TwitchStream.getStreamList(); //ids for stream
ArrayList<String> streamName = TwitchStream.getStreamName(); ... |
739b8b0a-f60e-4b88-8aae-e7779828115b | 9 | public final void shutdown() {
if (isShuttingDown) {
return;
}
isShuttingDown = true;
try {
if (soundPlayer != null) {
soundPlayer.running = false;
}
if (resourceThread != null) {
resourceThread.running = tr... |
32a6ecba-02f3-4371-9bb1-f2c643ac090b | 5 | public void play() {
if (sequence == null) {
throw new IllegalStateException("MidiAsset.play: " +
"Midi sequence not loaded");
}
if (sequencer == null) {
initialiseSequencer();
}
try {
sequencer.setSequenc... |
374e1a17-0025-4d41-b0fb-3f64e95a1280 | 9 | public JsonObject deleteActivity( JsonObject json ) {
// Get and validate parameters
JsonValue activityJsonValue = json.get("activity");
if ( activityJsonValue == null ) return new JsonObject().add("error", "Parameter activity is null");
if ( !activityJsonValue.isObject() ) return new JsonObject().add("error... |
a39e347d-f9c8-4a91-810a-c7b89e96285a | 5 | public void loadPropertiesForClass(String className){
try{
Properties props = new Properties();
String softwareProperties = System.getProperty(SOFTWARE_PROPERTIES);
props.load(new FileInputStream(softwareProperties != null ? softwareProperties : HARD_CODED_SOFTWARE_PROPERTIES... |
d386ecc4-7198-4aef-bdb8-776f4e9bfc52 | 1 | public boolean isRemover() {
return (remover) ? true : false;
} |
dea93c7a-c4c4-479d-8ca0-0945608995bf | 1 | public void addToInput(String input) {
if(!this.input.contains(input))
this.input.add(input);
} |
cc650c00-7302-4569-8fb7-dd3d83823522 | 5 | public void run() {
while (running) {
try {
sleep(10000);
//LazyHomer.setLastSeen();
for(Iterator<MargeObserver> iter = observers.keySet().iterator(); iter.hasNext(); ) {
MargeObserver obs = (MargeObserver)iter.next();
String url = observers.get(obs);
obs.remoteSignal("localhost","GET",... |
f685cbed-3ac8-4765-92eb-bba05fccfd07 | 6 | public void addEntry(Catalog cat, Node node) {
NodeList childNodes = node.getChildNodes();
Elev key = null;
HashMap<Materie, SituatieMaterieBaza> value = new HashMap<Materie, SituatieMaterieBaza>();
for (int i = 0; i < childNodes.getLength(); i++) {
Node cNode = childNodes.item(i);
if (cNode instanceof El... |
64a0408c-f38e-4947-9679-cc14d84aa1c8 | 6 | @Get("json")
public Representation _get() {
String keyword = getAttribute("keyword");
String query = format(FIND_RSRC, keyword);
Map<?, ?> anno = $annotations.findOne(query).as(Map.class);
if (anno == null) {
setStatus(Status.CLIENT_ERROR_NOT_FOUND);
return nu... |
61c070ae-e497-41dc-bcd6-ebdc92f1bb6f | 2 | public List<Row> getTopLevelRows() {
ArrayList<Row> list = new ArrayList<>();
for (Row row : mRows) {
if (row.getParent() == null) {
list.add(row);
}
}
return list;
} |
cafc98f8-3400-4d99-997a-23d3647fd2d8 | 3 | public void addSymbolsFromChilds(GoTerm goTerm) {
// Add symbols
for( String symbolId : symbolIdSet )
goTerm.addSymbolId(symbolId);
// Add interesting symbols
for( String symbolId : interestingSymbolIdSet )
goTerm.addInterestingSymbolId(symbolId);
// Recurse
for( GoTerm child : childs )
child.add... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.