method_id
stringlengths 36
36
| cyclomatic_complexity
int32 0
9
| method_text
stringlengths 14
410k
|
---|---|---|
65a25fda-8290-48f3-90d0-6fc14f409e4f | 5 | public LogInConnect(String name,String pw){
user_name=name;
pass_word=pw;
try{
@SuppressWarnings("resource")
Socket socket=new Socket("localhost",2553);
BufferedWriter out=new BufferedWriter(
new OutputStreamWriter(socket.getOutputStream()));
BufferedReader in=new BufferedReader(
new InputStreamReader(socket.getInputStream()));
while(true){
out.write(user_name,0,user_name.length());
out.write(" ");
out.write(pass_word,0,pass_word.length());
out.newLine();
out.flush();
break;
}
String msg;
while((msg=in.readLine())!=null){
JOptionPane.showMessageDialog(null,msg);
break;
}
if(msg.equals("Successfully Signed in."))
new UserAccountFrame(user_name).setVisible(true);
in.close();
} catch(UnknownHostException e){
System.out.println(e.getMessage());
System.exit(1);
} catch(IOException e){
//e.printStackTrace();
System.out.println(e.getMessage());
System.exit(1);
}
} |
c0441873-9383-41ae-9cd0-00aa0b8989e9 | 1 | protected CtMember.Cache hasMemberCache() {
if (memberCache != null)
return (CtMember.Cache)memberCache.get();
else
return null;
} |
0b8f638f-7007-4a07-a832-666a5326b90c | 3 | private static Method checkForCreatorMethod(Method m) {
if(m.getAnnotation(TestObjectCreate.class) == null)
return null;
if(!m.getReturnType().equals(testClass))
throw new RuntimeException("@TestObjectCreate " +
"must return instance of Class to be tested");
if((m.getModifiers() &
java.lang.reflect.Modifier.STATIC) < 1)
throw new RuntimeException("@TestObjectCreate " +
"must be static.");
m.setAccessible(true);
return m;
} |
974d571d-b57a-4b2c-8313-ef35c87cccea | 2 | @EventHandler
public void onPlayerDeath(PlayerRespawnEvent evt){
if(evt.getPlayer() == warden){
evt.getPlayer().teleport(locwar);
}else if(team.getPlayers().contains(evt.getPlayer())){
evt.getPlayer().teleport(cell1);
}
} |
37f8fee3-3e77-4847-802d-7d66d9c65798 | 3 | public static void main(String[] args) {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String host = "";
int port = 21025;
System.out.print("Enter Host: ");
try {
host = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
System.out.print("Enter Port (default 21025): ");
try{
port = Integer.parseInt(br.readLine());
} catch(NumberFormatException e){
// e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Client c = new Client(host, port);
c.start();
} |
d86bddb2-b947-46b4-95b7-b71c28a9d032 | 1 | public void visit_iadd(final Instruction inst) {
stackHeight -= 2;
if (stackHeight < minStackHeight) {
minStackHeight = stackHeight;
}
stackHeight += 1;
} |
2070ad49-7741-49f1-8190-b88b677f5138 | 0 | private void type()
{
expect(Token.Kind.IDENTIFIER);
} |
08b4c742-63a3-453c-90e7-b7946fa14d22 | 7 | @Override
public void write(int b) throws IOException {
count++;
if (count > MAX_BUFFER_SIZE) {
StringBuilder newBuffer = new StringBuilder(MAX_BUFFER_SIZE);
int brAfterPadding = buffer.indexOf("\n", BUFFER_PADDING);
newBuffer.append(buffer.subSequence(brAfterPadding, buffer.length()));
buffer = newBuffer;
}
char ch = (char) b;
if (ch == '$') {
command = true;
}
if (command) {
commandBuffer += ch;
} else {
buffer.append(ch);
}
if (ch == '\n') {
if (command) {
command = false;
if (commandBuffer.startsWith("$REFRESH")) {
}
} else {
if (chatout != null) {
chatout.setText(buffer.toString());
window.show();
}
}
}
} |
87b6dee6-6c41-4c32-8eb4-ceb541813d01 | 8 | public void Shoot(Direction d){
setChanged();
if (d==Direction.UP || d==Direction.DOWN){
for(int row=0; row<grid.length; ++row)
if (grid[row][currCol]==RoomState.WUMPUS){
setChanged();
this.notifyObservers(GameStatus.SHOTHIT);
}
this.notifyObservers(GameStatus.SHOTMISSED);
}
else if (d==Direction.RIGHT || d==Direction.LEFT){
for(int col=0; col<grid.length; ++col)
if (grid[currRow][col]==RoomState.WUMPUS){
setChanged();
this.notifyObservers(GameStatus.SHOTHIT);
}
this.notifyObservers(GameStatus.SHOTMISSED);
}
else
this.notifyObservers(GameStatus.SHOTMISSED);
} |
e53dd73d-6a41-4975-8892-ed468c136eee | 6 | private void drawSimplification() {
if (simplificationStep == -2) {
bufferGraphics.drawImage(strips[simplificationList.size()], 401, stripYPos[simplificationList.size()-1], this);
}
if (simplificationStep == 0) {
bufferGraphics.drawImage(strips[simplificationList.size()-1], 401, stripYPos[simplificationList.size()-1], this);
bufferGraphics.drawImage(simplifyingMolecules[0].getBallImage(), simplifyingMolecules[0].getPosition().x, simplifyingMolecules[0].getPosition().y, this);
bufferGraphics.drawImage(simplifyingMolecules[0].getNameImage(),
simplifyingMolecules[0].getPosition().x + 24 - simplifyingMolecules[0].getNameImage().getWidth()/2,
simplifyingMolecules[0].getPosition().y + 24 - simplifyingMolecules[0].getNameImage().getHeight()/2, this);
bufferGraphics.drawImage(simplifyingMolecules[1].getBallImage(), simplifyingMolecules[1].getPosition().x, simplifyingMolecules[1].getPosition().y, this);
bufferGraphics.drawImage(simplifyingMolecules[1].getNameImage(),
simplifyingMolecules[1].getPosition().x + 24 - simplifyingMolecules[1].getNameImage().getWidth()/2,
simplifyingMolecules[1].getPosition().y + 24 - simplifyingMolecules[1].getNameImage().getHeight()/2, this);
simplifyingMolecules[0].paintArrow((Graphics2D) bufferGraphics, this);
} else if (simplificationStep == 1) {
bufferGraphics.drawImage(strips[simplificationList.size()-2], 401, stripYPos[simplificationList.size()-2], this);
simplifyingMolecules[0].setArrowPos(overArrowAPos[simplificationList.size()-2].x, overArrowAPos[simplificationList.size()-2].y);
bufferGraphics.drawImage(simplifyingMolecules[0].getBallImage(), simplifyingMolecules[0].getPosition().x, simplifyingMolecules[0].getPosition().y, this);
bufferGraphics.drawImage(simplifyingMolecules[0].getNameImage(),
simplifyingMolecules[0].getPosition().x + 24 - simplifyingMolecules[0].getNameImage().getWidth()/2,
simplifyingMolecules[0].getPosition().y + 24 - simplifyingMolecules[0].getNameImage().getHeight()/2, this);
bufferGraphics.drawImage(rips[0], ripAPos[simplificationList.size()-2].x, ripAPos[simplificationList.size()-2].y, this);
bufferGraphics.drawImage(simplifyingMolecules[1].getBallImage(), overMolAPos[simplificationList.size()-2].x, overMolAPos[simplificationList.size()-2].y, this);
bufferGraphics.drawImage(simplifyingMolecules[1].getNameImage(),
overMolAPos[simplificationList.size()-2].x + 24 - simplifyingMolecules[1].getNameImage().getWidth()/2,
overMolAPos[simplificationList.size()-2].y + 24 - simplifyingMolecules[1].getNameImage().getHeight()/2, this);
simplifyingMolecules[0].paintArrow((Graphics2D) bufferGraphics, this);
} else if (simplificationStep == 2 || simplificationStep == 3) {
bufferGraphics.drawImage(strips[simplificationList.size()-2], 401, stripYPos[simplificationList.size()-2], this);
simplifyingMolecules[0].setArrowPos(overArrowBPos[simplificationList.size()-2].x, overArrowBPos[simplificationList.size()-2].y);
bufferGraphics.drawImage(rips[1], ripBPos[simplificationList.size()-2].x, ripBPos[simplificationList.size()-2].y, this);
bufferGraphics.drawImage(simplifyingMolecules[1].getBallImage(), overMolBPos[simplificationList.size()-2].x, overMolBPos[simplificationList.size()-2].y, this);
bufferGraphics.drawImage(simplifyingMolecules[1].getNameImage(),
overMolBPos[simplificationList.size()-2].x + 24 - simplifyingMolecules[1].getNameImage().getWidth()/2,
overMolBPos[simplificationList.size()-2].y + 24 - simplifyingMolecules[1].getNameImage().getHeight()/2, this);
simplifyingMolecules[0].paintArrow((Graphics2D) bufferGraphics, this);
}
if (simplificationStep == 3) {
bufferGraphics.drawImage(imageMap.get("eraserMark"), eraserMarkPos[simplificationList.size()-2].x, eraserMarkPos[simplificationList.size()-2].y, this);
}
} |
bef1777a-d1bd-4641-8bc4-7eddb20754a2 | 4 | public QuadTree[] getQuadTrees()
{
if (NW == null && NE == null && SW == null && SE == null)
{
return new QuadTree[0];
} else
{
return new QuadTree[]
{
NW, NE, SW, SE
};
}
} |
0accfa78-d37d-48c8-8b7c-95f1ff4dec78 | 0 | public String[] getElementsUnbalanced() {
return this.ELEMENTS_UNBALANCED;
} |
1b8bfcd2-ff5f-4ebc-9a0a-cc95f50bf798 | 6 | @Override
public void update(int delta) {
if (!hasMob && respawnTime >= respawnMax){
respawnTime = 0;
createMob();
}
else if (!hasMob){
respawnTime += delta;
}
else if (hasMob){
mob.update(delta);
if (mob.isDead()){
tmx.runLootTable(mob);
mob = null;
hasMob = false;
}
else if (mob.isDespawned()){
mob = null;
hasMob = false;
}
}
} |
b3b0730a-76db-4544-a9d2-0b10e02d4823 | 1 | public void setImage(Image image) {
button.setIcon(image == null ? null : new ImageIcon(image));
} |
ee4a0296-b58f-4d70-babd-88a6d938a61e | 4 | public void propScoreAdd(int type){
if( type == PropType.star){
Game.propScore += 150 ;
}else if( type == PropType.life){
Game.propScore += 500 ;
}else if( type == PropType.hat){
Game.propScore += 200 ;
}else if( type == PropType.mime){
Game.propScore += 100 ;
}
} |
686679fd-43aa-4d01-b9b7-c35ac862297f | 8 | @SuppressWarnings("unchecked")
private Behavior loadBehaviorClass(File compiledFile) {
FileClassLoader fcl = new FileClassLoader(BehaviorLoader.class.getClassLoader());
Class<Behavior> behClass = null;
// get the class
try {
behClass = fcl.loadClassFromFile(compiledFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
// get the constructor
Constructor<Behavior> behConstructor = null;
try {
behConstructor = behClass.getConstructor();
} catch (SecurityException e) {
e.printStackTrace();
return null;
} catch (NoSuchMethodException e) {
e.printStackTrace();
return null;
}
// construct the player
Behavior beh = null;
try {
beh = behConstructor.newInstance();
} catch (IllegalArgumentException e) {
e.printStackTrace();
return null;
} catch (InstantiationException e) {
e.printStackTrace();
return null;
} catch (IllegalAccessException e) {
e.printStackTrace();
return null;
} catch (InvocationTargetException e) {
e.printStackTrace();
return null;
}
return beh;
} |
b0658b44-d0b1-4270-837a-3568e2a57191 | 2 | private static void readInGrafo(Core output, Document xml, String updateId) {
long source = Long.parseLong(xml.getElementsByTagName(SOURCE).item(HEAD).getTextContent());
long target = Long.parseLong(xml.getElementsByTagName(TARGET).item(HEAD).getTextContent());
NodeList dispositivos = xml.getElementsByTagName(DISPOSITIVO);
List<Dispositivo> dispositivosList = new List<Dispositivo>();
for (int i = 0; i < dispositivos.getLength(); i++) {
Element nodo = (Element) dispositivos.item(i);
Dispositivo ele = new Dispositivo(nodo.getAttribute(ID), nodo.getAttribute(TIPO), nodo.getAttribute(PUERTO));
dispositivosList.append(ele);
}
NodeList conexiones = xml.getElementsByTagName(CONEXION);
List<Connection> conexionesList = new List<Connection>();
for (int i = 0; i < conexiones.getLength(); i++) {
Element nodo = (Element) conexiones.item(i);
Connection ele = new Connection(Long.parseLong(nodo.getAttribute(SOURCE)), Long.parseLong(nodo.getAttribute(TARGET)),
Integer.parseInt(nodo.getAttribute(PRECIO)));
conexionesList.append(ele);
}
} |
7e0bed6c-647b-4fe5-a272-bfc27bd79955 | 9 | private boolean convertYUV422toRGB(int[] y, int[] u, int[] v, int[] rgb)
{
if (this.upSampler != null)
{
// Requires u & v of same size as y
this.upSampler.superSampleHorizontal(u, u);
this.upSampler.superSampleHorizontal(v, v);
return this.convertYUV444toRGB(y, u, v, rgb);
}
final int half = this.width >> 1;
final int rgbOffs = this.offset;
int oOffs = 0;
int iOffs = 0;
int k = 0;
for (int j=0; j<this.height; j++)
{
for (int i=0; i<half; i++)
{
int r, g, b, yVal, uVal, vVal;
final int idx = oOffs + i + i;
// ------- toRGB 'Macro'
yVal = y[k++] << 12;
uVal = u[iOffs+i];
vVal = v[iOffs+i];
r = yVal + 3916*uVal + 2544*vVal;
g = yVal - 1114*uVal - 2650*vVal;
b = yVal - 4530*uVal + 6976*vVal;
if (r >= 1042432) r = 0x00FF0000;
else { r &= ~(r >> 31); r = (r + 2048) >> 12; r <<= 16; }
if (g >= 1042432) g = 0x0000FF00;
else { g &= ~(g >> 31); g = (g + 2048) >> 12; g <<= 8; }
if (b >= 1042432) b = 0x000000FF;
else { b &= ~(b >> 31); b = (b + 2048) >> 12; }
// ------- toRGB 'Macro' END
rgb[idx+rgbOffs] = r | g | b;
// ------- toRGB 'Macro'
yVal = y[k++] << 12;
r = yVal + 3916*uVal + 2544*vVal;
g = yVal - 1114*uVal - 2650*vVal;
b = yVal - 4530*uVal + 6976*vVal;
if (r >= 1042432) r = 0x00FF0000;
else { r &= ~(r >> 31); r = (r + 2048) >> 12; r <<= 16; }
if (g >= 1042432) g = 0x0000FF00;
else { g &= ~(g >> 31); g = (g + 2048) >> 12; g <<= 8; }
if (b >= 1042432) b = 0x000000FF;
else { b &= ~(b >> 31); b = (b + 2048) >> 12; }
// ------- toRGB 'Macro' END
rgb[idx+rgbOffs+1] = r | g | b;
}
oOffs += this.stride;
iOffs += half;
}
return true;
} |
72f75a67-bcc2-4b04-a8f4-befe03ed3426 | 4 | private void height() {
if (this.isEmpty())
this.height = 0;
else if (this.isLeaf())
this.height = 1;
else if (this.getLeft() == null)
this.height = 1 + this.getRight().height;
else if (this.getRight() == null)
this.height = 1 + this.getLeft().height;
else
this.height = 1 + Math.max(this.getLeft().height, this.getRight().height);
} |
683226e9-dad6-4512-882c-6cd65a80c9cc | 8 | @Override
public void unInvoke()
{
if(canBeUninvoked() && (!super.unInvoked))
{
if((affected!=null)&&(affected instanceof MOB)&&(!helping))
{
final MOB mob=(MOB)affected;
if(!aborted)
{
if((messedUp)&&(room!=null))
{
notifyMessUp(mob, recipe);
}
else
{
this.buildComplete(mob, recipe, room, dir, designTitle, designDescription);
}
}
}
}
super.unInvoke();
} |
decdaa64-9dcf-447a-8428-20e2a8c42fbc | 4 | private void handleMouseOverEvents(Input input) {
int buttonIndex = 0;
for (Button button : buttons) {
if (!(button instanceof Button.BlankButton)) { // Don't want tooltip
// for blank button
if (button.isMouseOver(input)) {
for (ButtonRowListener listener : listeners) {
listener.buttonMouseOver(this, button, buttonIndex);
}
}
}
buttonIndex++;
}
} |
1f32a41e-8a67-456a-beb6-604be275eeac | 1 | public String toString() {
if (name == null) {
return "Local$" + index;
}
return name + "$" + index;
} |
26d2d38d-0035-465d-af9c-7fb552ab8690 | 3 | public String[][] getConnectedPlayers() {
String playerNamesList = "";
int ACTIVE_CONNECTIONS = 0;
ACTIVE_CONNECTIONS = getActiveConnections();
// Now ask about their details:
outToServer.println("FETCHPLAYERS");
String totalPlayerArray[][] = new String[(ACTIVE_CONNECTIONS +1)][5];
try {
playerNamesList = inFromServer.readLine();
String[] unprocessedPlayerNames = playerNamesList.split(",");
System.out.println("Unprocessed Player Names Length: " + unprocessedPlayerNames.length);
int processed = 0;
while(processed < unprocessedPlayerNames.length) {
totalPlayerArray[processed][0] = unprocessedPlayerNames[processed];
processed++;
}
processed = 0;
while(processed < totalPlayerArray.length) {
System.out.println(totalPlayerArray[processed][0]);
processed++;
}
return totalPlayerArray;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
} |
2e584742-5f3e-4090-b5c1-f1f1e4226586 | 6 | public article parseH5Introduction(selectObj selectObj, urlObj urlObj) throws IOException {
Document doc = Jsoup.connect(urlObj.getUrl()).get();
Elements elements = doc.select(selectObj.getDocumentSelect());
System.out.println("Fetching : " + urlObj.getUrl());
article article = new article();
for (int i =0; i< elements.size(); i++){
Element element = elements.get(i);
String t = element.text();
switch (i){
case 0:
article.setName(t.substring(1,t.length()-1));
break;
case 1:
article.setInstroduction(t.substring(3,t.length()));
break;
case 2:
article.setAuthor(t.substring(3,t.length()));
break;
case 3:
article.setYears(t.substring(3,t.length()));
break;
}
}
for (Element link : elements) {
System.out.println(link.text());
}
return article;
} |
29489089-47be-48b8-a421-cc67e57fd0fd | 5 | public About (JFrame parent) {
super(parent,"\u00DCber das Programm");
setModalityType(ModalityType.APPLICATION_MODAL);
setLayout(new BorderLayout());
JPanel p = new JPanel (new FlowLayout ());
p = new JPanel (new FlowLayout ());
p.add (new JLabel ("Camp Planer " + MainWindow.versionString));
add (p, BorderLayout.NORTH);
String s = "Fehler!";
try {
char[] c = new char [2048];
if (ClassLoader.getSystemResource("text/About.txt") != null) {
InputStream in = ClassLoader.getSystemResource("text/About.txt").openStream();
if (in != null) {
InputStreamReader r = new InputStreamReader (in);
r.read(c);
s = new String (c);
}
}
else {
FileReader r = new FileReader ("text/About.txt");
r.read(c);
r.close();
s = new String (c);
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
JTextArea t = new JTextArea (s);
t.setEditable(false);
add (t, BorderLayout.CENTER);
JButton btnOk = new JButton ("Ok");
btnOk.addActionListener(this);
p = new JPanel (new FlowLayout ());
p.add (btnOk);
add (p, BorderLayout.SOUTH);
int width = t.getPreferredSize().width + 10;
if (width > 400)
width = 400;
int height = t.getPreferredSize().height + 100;
setMinimumSize(new Dimension (width, height));
setLocationByPlatform(true);
setResizable(false);
} |
59aeab6c-30fd-4759-842e-7ca3d0a66bbc | 3 | public void save()
{
String savePath = new Control_GetPath().getStreamRipStarPath();
XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
int[] intOptions = new int[5];
try {
XMLEventWriter writer = outputFactory.createXMLEventWriter( new FileOutputStream(savePath+"/ScheduleManager.xml" ), "UTF-8" );
XMLEventFactory eventFactory = XMLEventFactory.newInstance();
//save Intgers of the widths of any cell that is shown
for(int i=0; i < intOptions.length;i++)
{
intOptions[i] = table.getColumn(schedulHeader[i+2]).getWidth();
}
//header for the file
XMLEvent header = eventFactory.createStartDocument();
XMLEvent startRootSettings = eventFactory.createStartElement( "", "", "Settings" );
XMLEvent height = eventFactory.createAttribute( "height", String.valueOf( getSize().height));
XMLEvent width= eventFactory.createAttribute( "width", String.valueOf( getSize().width));
XMLEvent i0 = eventFactory.createAttribute( "i0", String.valueOf( intOptions[0] ));
XMLEvent i1 = eventFactory.createAttribute( "i1", String.valueOf( intOptions[1] ));
XMLEvent i2 = eventFactory.createAttribute( "i2", String.valueOf( intOptions[2] ));
XMLEvent i3 = eventFactory.createAttribute( "i3", String.valueOf( intOptions[3] ));
XMLEvent i4 = eventFactory.createAttribute( "i4", String.valueOf( intOptions[4] ));
XMLEvent endRoot = eventFactory.createEndElement( "", "", "Settings" );
XMLEvent endDocument = eventFactory.createEndDocument();
//finally write into file
writer.add( header );
writer.add( startRootSettings );
writer.add( height );
writer.add( width );
writer.add( i0 );
writer.add( i1 );
writer.add( i2 );
writer.add( i3 );
writer.add( i4 );
writer.add( endRoot );
writer.add( endDocument );
writer.close();
} catch (FileNotFoundException e) {
SRSOutput.getInstance().logE( "Gui_ScheduleManager: Can't find file ScheduleManager.xml" );
} catch (XMLStreamException e) {
SRSOutput.getInstance().logE( "Gui_ScheduleManager:"+e.getMessage() );
}
} |
3df188cf-101b-4b69-9d1e-2804ade841ec | 7 | public int maxDonationsWrapper(int[] donations) {
int[] T = new int[donations.length];
int[] P = new int[donations.length];
T[0] = donations[0];
P[0] = -1;
for (int i = 1; i < T.length; i++) {
int max = Integer.MIN_VALUE;
for (int j = 0; j < i - 1; j++) {
if (max < T[j] + donations[i]) {
if (i == T.length - 1) {
if (checkNotIncludingFirst(P, j)) {
max = T[j] + donations[i];
P[i] = j;
}
} else {
max = T[j] + donations[i];
P[i] = j;
}
}
}
if (max < donations[i]) {
max = donations[i];
P[i] = -1;
}
T[i] = max;
}
int max = Integer.MIN_VALUE;
for (int i = 0; i < T.length; i++)
max = Math.max(T[i], max);
return max;
} |
6a6de79f-50ed-4016-84a6-288f8c7d61c2 | 7 | public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
ConsolePlayerMessage send = new ConsolePlayerMessage(sender);
if(cmd.getName().equalsIgnoreCase("clickless")){
ArrayList<ClicklessSign> signs = getClickless().getSigns();
if(args.length >= 0){
if(args[0].toLowerCase().equals("signs")){
String msg = signs.size() +" Signs:";
for(int i = 0; i < signs.size(); i++){
msg += new LocationTool(signs.get(i).getLocation()).getLocationString() + "\n";
}
send.sendMessage(msg);
}
if(args[0].toLowerCase().equals("questioner")){
ArrayList<MicroQuestioner> questiones_ = questiones.getQuestioners();
for(int i = 0; i < questiones_.size(); i++){
log.info(questiones_.get(i).getPlayer() + ": '" + questiones_.get(i).getQuestion() + "'");
}
return true;
}
if(args[0].toLowerCase().equals("help")){
send.sendMessage("/clickless signs: list all registered signs\n" +
"/clickless help: this help text");
}
}
}
return true;
} |
de471ca3-ad0f-4c57-8dbd-b5938bddfa66 | 6 | @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ImgPerson)) {
return false;
}
ImgPerson other = (ImgPerson) obj;
if (username == null) {
if (other.username != null) {
return false;
}
} else if (!username.equalsIgnoreCase(other.username)) {
return false;
}
return true;
} |
633c07d7-bcc9-4c92-96f2-3f298045cf13 | 0 | public EntityManager getEntityManager() {
return em;
} |
33283853-d146-49eb-8197-96c64897dc22 | 2 | public static String likePurviewCode(String alias,String puriveCode,String columnName){
if(puriveCode == null){
return "";
}
if(isBlank(alias)){
alias = "";
}else{
alias += ".";
}
StringBuilder sb = new StringBuilder();
sb.append(" ( ");
sb.append(alias).append(columnName).append(" like '").append(puriveCode).append("%'");
sb.append(" ) ");
return sb.toString();
} |
5b2728d3-71b4-4489-8aa2-90b5ff7aa60c | 0 | public JFrame getFrame(){
return frame;
} |
8330198b-e6dc-42f7-a581-fe4dd4738f31 | 3 | public static double studentTCDF(double tValue, int df) {
if (tValue != tValue) throw new IllegalArgumentException("argument tValue is not a number (NaN)");
if (tValue == Double.POSITIVE_INFINITY) {
return 1.0;
} else {
if (tValue == Double.NEGATIVE_INFINITY) {
return 0.0;
} else {
double ddf = df;
double x = ddf / (ddf + tValue * tValue);
return 0.5D * (1.0D + (Stat.regularisedBetaFunction(ddf / 2.0D, 0.5D, 1) - Stat.regularisedBetaFunction(ddf / 2.0D, 0.5D, x)) * Fmath.sign(tValue));
}
}
} |
217da409-b407-4ed2-89ae-a711bbc1e7f8 | 0 | public SearchForGameThread(PongWindow window) throws SocketException {
super("SearchForGameThread");
this.window = window;
socket = new DatagramSocket(4445);
} |
62a46084-cc50-4547-975c-36f4b02671f8 | 3 | @Override
public int neighbourhoodBest(int particle) {
int cubeRoot = getCubeRoot();
if(cubeRoot == 1){
return particle;
}else if(particle < cubeRoot * cubeRoot){
Vector<Integer> temp = particlesOnPlane(particle, cubeRoot);
temp.add(particle);
temp.add(particle + cubeRoot * cubeRoot);
return getfittestParticle(temp);
}else if(particle >= solutionFitness.size() - cubeRoot * cubeRoot){
Vector<Integer> temp = particlesOnPlane(particle, cubeRoot);
temp.add(particle);
temp.add(particle - cubeRoot * cubeRoot);
return getfittestParticle(temp);
}else{
Vector<Integer> temp = particlesOnPlane(particle, cubeRoot);
temp.add(particle);
temp.add(particle - cubeRoot * cubeRoot);
temp.add(particle + cubeRoot * cubeRoot);
return getfittestParticle(temp);
}
} |
0e1a713e-72ac-4302-bcfa-2f02d28cb1b4 | 6 | @Override
public void caseADeclEscrevaDefinicaoComando(ADeclEscrevaDefinicaoComando node)
{
inADeclEscrevaDefinicaoComando(node);
if(node.getEscreva() != null)
{
node.getEscreva().apply(this);
}
if(node.getLPar() != null)
{
node.getLPar().apply(this);
}
if(node.getMultiplaExp() != null)
{
node.getMultiplaExp().apply(this);
}
if(node.getExp() != null)
{
node.getExp().apply(this);
}
if(node.getRPar() != null)
{
node.getRPar().apply(this);
}
if(node.getPontoVirgula() != null)
{
node.getPontoVirgula().apply(this);
}
outADeclEscrevaDefinicaoComando(node);
} |
1c474833-6d46-4268-9cf5-9f1537382daf | 7 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Autore other = (Autore) obj;
if (annoNascita != other.annoNascita)
return false;
if (nome == null) {
if (other.nome != null)
return false;
} else if (!nome.equals(other.nome))
return false;
return true;
} |
acecdce8-b320-41be-abec-25dbc100c5f5 | 8 | private STS transformCondition(Condition condition, int prevIndex) {
init();
State initialState = createState();
logger.trace("Transforming condition " + condition);
StateFormula condNoNegations =
condition.getFormula().getEquivalentFormulaWithoutNegations();
Map<ObjectTransition, DomainObject> transToUpdate =
new HashMap<ObjectTransition, DomainObject>();
StateFormula condNoUncontrollable =
this.transformUncontrollableLiterals(condNoNegations, transToUpdate);
if (!transToUpdate.isEmpty()) {
State nextState = createState();
int index = condition.getIndex();
Action trigger = new DefaultAction("Trigger" + index, false, condition);
Action notrigger = new DefaultAction("NoTrigger" + index, false, condition);
action2cond.put(trigger, condition);
action2cond.put(notrigger, condition.getNegation());
outputActions.add(trigger);
outputActions.add(notrigger);
DefaultLiteral traceLit = new DefaultLiteral("Trace" + index);
DefaultLiteral pointLit = new DefaultLiteral("Point" + index);
DefaultClause flagClause = new DefaultClause();
DefaultClause completeFlagClause = new DefaultClause();
for (int i = 0; i < index; i++) {
DefaultLiteral flagLit = new DefaultLiteral("flag" + i);
completeFlagClause.addLiteral(flagLit);
if (i >= prevIndex) {
flagClause.addLiteral(flagLit);
}
}
Set<Clause<? extends Literal>> clauses =
this.getRightPointClauses(traceLit, pointLit, flagClause);
Transition triggerTrans = createTransition(initialState,
condNoUncontrollable, trigger, nextState);
triggerTrans.addGuardClauses(clauses);
Transition noTriggerTrans = createTransition(initialState,
new StateFormula(), notrigger, nextState);
noTriggerTrans.addGuardClauses(clauses);
Action reset = new DefaultAction("UNDEF", false, condition);
outputActions.add(reset);
// Transition resetTrans = createTransition(nextState, new StateFormula(), reset, initialState);
// resetTrans.addGuardClause(flagClause);
Transition stayTrans = createTransition(nextState, new StateFormula(), reset, nextState);
for (int i = 0; i < index; i++) {
DefaultLiteral negFlagLit = new DefaultLiteral("flag" + i, true);
DefaultClause negFlagClause = new DefaultClause(negFlagLit);
stayTrans.addGuardClause(negFlagClause);
}
Correction corr = corrections.get(condition.getIndex() - 1);
ProcessModel matchingAdaptationModel = corr.getAdaptation().getAdaptationModel();
// Action adUndef = new DefaultAction("UNDEF", true, matchingAdaptationModel);
for (ProcessModel model : processModels) {
if (!model.equals(matchingAdaptationModel)) {
Action otherwiseAct = new WildcardAction(true, model);
inputActions.add(otherwiseAct);
Transition trans = createTransition(nextState, StateFormula.getTop(), otherwiseAct, initialState);
trans.addGuardClause(completeFlagClause);
}
}
Transition resetTrans2 = createTransition(initialState, new StateFormula(), reset, initialState);
for (int i = prevIndex; i < index; i++) {
DefaultLiteral flagLit = new DefaultLiteral("flag" + i);
DefaultClause guardClause =
new DefaultClause(traceLit.getNegation(), pointLit.getNegation(), flagLit.getNegation());
resetTrans2.addGuardClause(guardClause);
}
this.updateDomainObjectTransitions(transToUpdate, trigger, clauses);
}
return new DefaultSTS(states, initialState, inputActions,
outputActions, transitions);
} |
a9d7bcaf-485a-4331-a985-1c724e1f0300 | 5 | private static boolean equal(Color[][] colors1, Color[][] colors2) {
if (colors1.length != colors2.length
|| colors1[0].length != colors2[0].length) {
return false;
}
for (int row = 0; row < colors1.length; row++) {
for (int col = 0; col < colors1[row].length; col++) {
if (colors1[row][col] != colors2[row][col]) {
return false;
}
}
}
return true;
} |
7f05e8d5-d3b9-4729-b139-e491aafafa62 | 4 | public Rectangle2D.Float getMediaBox() {
// add all of the pages media box dimensions to a vector and process
Vector boxDimensions = (Vector) (library.getObject(entries, "MediaBox"));
if (boxDimensions != null) {
mediaBox = new PRectangle(boxDimensions);
// System.out.println("Page - MediaBox " + mediaBox);
}
// If mediaBox is null check with the parent pages, as media box is inheritable
if (mediaBox == null) {
PageTree pageTree = getParent();
while (pageTree != null && mediaBox == null) {
mediaBox = pageTree.getMediaBox();
pageTree = pageTree.getParent();
}
}
return mediaBox;
} |
30336695-7d49-4268-983d-ea9f0381d208 | 6 | public static int dehexchar(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
}
if (c >= 'A' && c <= 'F') {
return c - ('A' - 10);
}
if (c >= 'a' && c <= 'f') {
return c - ('a' - 10);
}
return -1;
} |
30d50da7-459e-41e5-822d-7f57b163d429 | 1 | private void updateTextureOffsets(Transform transform) {
Vector4f textureOffsets = transform.textureOffsets;
if(textureOffsets == null) {
texXOffset = 0;
texYOffset = 0;
texWidth = texture.getWidth();
texHeight = texture.getHeight();
} else {
texXOffset = textureOffsets.x;
texYOffset = textureOffsets.y;
texWidth = textureOffsets.z;
texHeight = textureOffsets.w;
}
} |
ddcee3ce-b90e-4479-95f1-a306448e2e05 | 8 | public BigDecimal calculaTaxa(Transferencia transferencia){
BigDecimal taxa = BigDecimal.ZERO;
Date dt = transferencia.getDataTransferencia();
int dias = calculaPrazo(dt);
try{
//maior que 30 dias da data de cadastro - 1.2%
if(dias > 30){
AplicaTaxaTipoC taxaC = new AplicaTaxaMaiorQueTrintaDias();
taxa = taxaC.aplicarTaxa(transferencia.getValorTransferencia());
}
//até 30 dias da data de cadastro - 2.1%
if(dias <= 30){
AplicaTaxaTipoC taxaC = new AplicaTaxaAteTrintaDias();
taxa = taxaC.aplicarTaxa(transferencia.getValorTransferencia());
}
//até 25 dias da data de cadastro - 4.3%
if(dias <= 25){
AplicaTaxaTipoC taxaC = new AplicaTaxaAteVinteCincoDias();
taxa = taxaC.aplicarTaxa(transferencia.getValorTransferencia());
}
//até 20 dias da data de cadastro - 5.4%
if(dias <= 20){
AplicaTaxaTipoC taxaC = new AplicaTaxaAteVinteDias();
taxa = taxaC.aplicarTaxa(transferencia.getValorTransferencia());
}
//até 15 dias da data de cadastro - 6.7%
if(dias <= 15){
AplicaTaxaTipoC taxaC = new AplicaTaxaAteQuinzeDias();
taxa = taxaC.aplicarTaxa(transferencia.getValorTransferencia());
}
//até 10 dias da data de cadastro - 7.4%
if(dias <= 10){
AplicaTaxaTipoC taxaC = new AplicaTaxaAteDezDias();
taxa = taxaC.aplicarTaxa(transferencia.getValorTransferencia());
}
//até 5 dias da data de cadastro - 8.3%
if(dias <= 5){
AplicaTaxaTipoC taxaC = new AplicaTaxaAteCincoDias();
taxa = taxaC.aplicarTaxa(transferencia.getValorTransferencia());
}
}catch(ArithmeticException e){
throw new ArithmeticException(e.getMessage());
}
return taxa;
} |
1b4373a4-8a44-4469-af83-3ecc8e6d7d42 | 7 | public void doTransformations() {
if (GlobalOptions.verboseLevel > 0)
GlobalOptions.err.println("Transforming " + this);
info.setName(getFullAlias());
transformSuperIfaces();
transformInnerClasses();
Collection newFields = new ArrayList(fieldIdents.size());
Collection newMethods = new ArrayList(methodIdents.size());
for (Iterator i = fieldIdents.iterator(); i.hasNext();) {
FieldIdentifier ident = (FieldIdentifier) i.next();
if ((Main.stripping & Main.STRIP_UNREACH) == 0
|| ident.isReachable()) {
ident.doTransformations();
newFields.add(ident.info);
}
}
for (Iterator i = methodIdents.iterator(); i.hasNext();) {
MethodIdentifier ident = (MethodIdentifier) i.next();
if ((Main.stripping & Main.STRIP_UNREACH) == 0
|| ident.isReachable()) {
ident.doTransformations();
newMethods.add(ident.info);
}
}
info.setFields((FieldInfo[]) newFields.toArray(new FieldInfo[newFields
.size()]));
info.setMethods((MethodInfo[]) newMethods
.toArray(new MethodInfo[newMethods.size()]));
} |
417fe02b-a699-4a6c-a758-7de5683d185e | 9 | public static void addPatientObservation( Patient patient, Observation obs, ObservationType ot, String observations ) {
Connection conn = null;
Connection conn2 = null;
PreparedStatement ps = null;
PreparedStatement ps2 = null;
ResultSet rs = null;
try {
// Get a connection to the specified JDBC URL.
double oid = -1;
conn = JDBCConnection.getConnection();
conn2 = JDBCConnection.getConnection();
String query = "INSERT INTO observations ( pid, type_id, date_observed, time_observed, date_recorded, time_recorded ) ";
query += "VALUES ( ?, ?, ?, ?, ?, ? )";
// Create a Statement object for sending SQL statements to the database.
// Statement: The object used for executing a static SQL statement and returning the results it produces.
ps = conn.prepareStatement(query, new String[] {"oid"} );
ps.setDouble( 1, patient.getPid() );
ps.setInt( 2, ot.getType_id());
ps.setDate( 3, obs.getDate_observed());
ps.setString( 4, obs.getHours() +":"+obs.getMinutes());
ps.setDate(5, obs.getDate_recorded());
ps.setString( 6, obs.getTime_recorded());
ps.executeUpdate();
rs = ps.getGeneratedKeys();
if ( rs != null && rs.next() ) {
oid = rs.getDouble(1);
String names[] = parseColumnNames( ot.getColumn_names_types() );
String types[] = parseColumnTypes( ot.getColumn_names_types() );
query = "INSERT INTO "+ ot.getTable_name() +" ( oid";
for ( int i = 0; i < names.length; i++ ) {
query += ", " + names[i];
}
query += " ) VALUES ( ?";
for ( int i = 0; i < types.length; i++ ) {
query += ", ?";
}
query += " )";
ps2 = conn2.prepareStatement(query);
ps2.setDouble(1, oid);
String observationColumn[] = parseColumnNames( observations );
String observationValues[] = parseColumnTypes( observations );
for ( int i = 0; i < observationColumn.length; i++ ) {
for ( int j = 0; j < observationColumn.length; j++ ) {
if ( names[i].equals(observationColumn[j])) {
if ( types[i].equals("String")) {
ps2.setString((i+2), observationValues[j]);
} else {
ps2.setInt((i+2), Integer.valueOf(observationValues[j]));
}
}
}
}
ps2.execute();
}
} catch(SQLException e) {
e.printStackTrace();
} finally {
JDBCConnection.closeConnection(conn, ps, rs);
JDBCConnection.closeConnection(conn2, ps2, null);
}
} |
44f94937-84d1-4021-8b40-927668804935 | 4 | @Override
public boolean equals(Object o) {
if(o instanceof Piece) {
Piece p = (Piece)o;
if(p.getX() == getX() && p.getY() == getY() && p.getColor() == getColor()) {
return true;
}
}
return false;
} |
0e00604c-4f99-4de2-bdf1-b76240afdc3d | 7 | public V put(K key, V value) {
if (key == null) {
key = (K) KeyFactory.NULL;
}
cleanup();
// Make sure the key is not already in the WeakIdentityMap.
Entry[] tab = this.table;
int hash = System.identityHashCode(key);
int index = (hash & 0x7fffffff) % tab.length;
for (Entry e = tab[index], prev = null; e != null; e = e.next) {
Object entryKey = e.get();
if (entryKey == null) {
// Clean up after a cleared Reference.
this.modCount++;
if (prev != null) {
prev.next = e.next;
} else {
tab[index] = e.next;
}
this.count--;
} else if (e.hash == hash && key == entryKey) {
Object old = e.value;
e.value = value;
return (V) old;
} else {
prev = e;
}
}
this.modCount++;
if (this.count >= this.threshold) {
// Rehash the table if the threshold is still exceeded.
rehash();
tab = this.table;
index = (hash & 0x7fffffff) % tab.length;
}
// Creates the new entry.
Entry e = new Entry(hash, key, this.queue, value, tab[index]);
tab[index] = e;
this.count++;
return null;
} |
c1e9dd1a-cf09-40f3-9b38-92edb0399f7e | 5 | public int hashIntArray(int[] array) {
int a = 0xdeadbeef + ((array.length)<<2);
int[] tab = new int[3];
tab[0] = tab[1] = tab[2] = a;
int pt = 0;
int length = array.length;
while(length>3){
tab[0] += array[pt];
tab[1] += array[pt+1];
tab[2] += array[pt+2];
mix(tab);
length -= 3;
pt += 3;
}
switch(length){
case 3:
tab[2] += array[pt+2];
case 2:
tab[1] += array[pt+1];
case 1:
tab[0] += array[pt];
finalMix(tab);
case 0:
break;
}
return tab[2];
} |
58d89f36-5bf4-40b1-93d2-79503794462a | 0 | public int getExpYear() {
return expYear;
} |
4e3baf0f-bb20-4da4-95e0-a809a8ff16f9 | 0 | @Override
public void mouseEntered(MouseEvent e) {} |
43843567-167a-400b-8e0c-4551bfde6085 | 4 | public int getID( int whichID ) {
if( whichID < 0 && whichID > 3 )
return -1;
try {
ResultSet result = SQL_SEARCH[ whichID ].executeQuery();
if( result.first() ) {
return result.getInt( 1 );
} else {
return -1;
}
} catch ( Exception e ) {
e.printStackTrace();
return -1;
}
} |
7098b0e6-8868-4374-993f-edbb38b9ca24 | 5 | private void displayHelp(String helpType) {
String helpText = null;
switch (helpType) {
case HelpMenuView.BOARD: helpText =
"\tThe game board for Sudoku. It consist of a grid of "
+ "\n\tlocations. Players type the numbers 1-9 on the different locations "
+ "\n\ton the board in an effort to complete the puzzle. The default board is "
+ "\n\t9 rows by 9 columns.";
break;
case HelpMenuView.GAME: helpText =
"\tThe objective of the game is to fill in the remaining blank spaces "
+ "\n\twith the numbers 1-9. Each row vertically and horizontally must "
+ "\n\tcontain the numbers 1-9 as well as each of the smaller 3x3 squares. "
+ "\n\tEach smaller 3x3 square and each horizontal and vertical row "
+ "\n\tmust contain the numbers 1-9 NO DUPLICATES in each case, "
+ "\n\tin order for the puzzle to be completed successfully.";
break;
case HelpMenuView.LOCATION: helpText =
"\tA location on the board where a player can place a number 1-9";
break;
case HelpMenuView.MARKER: helpText =
"\tThe numbers 1-9 that \"mark\" the number sequences on the board "
+ "by a player. "
+ "\n\tThe default markers are the numbers \"1-9\".";
break;
}
StringBuilder dividerLine = new StringBuilder(80);
for (int i = 0; i < 80; i++) {
dividerLine.insert(i, '~');
}
System.out.println("\t" + dividerLine.toString());
System.out.println(helpText);
System.out.println("\t" + dividerLine.toString());
} |
46c6a46d-7191-409c-a8a9-1cf1255b1b33 | 7 | private byte[] zeroCompressDataIntoTable(int imageWidth, int imageHeight, byte[] uncompactedData, byte[] zeroCompressionTableData)
{
byte pessimisticCompactedData[] = new byte[uncompactedData.length];
int lineDataOffset = 0;
int uncompactedByteArrayIndex = 0;
for (int row = 0; row < imageHeight; ++row)
{
int tableBase = row * ZERO_COMPRESSION_TABLE_DATA_SIZE;
int dataBase = row * imageWidth;
short lineDataStart = 0;
short lineDataEnd = 0;
int col = 0;
while ((col < imageWidth) && (0 == uncompactedData[dataBase + col]))
{
col++;
lineDataStart++;
}
short zerosAtEndOfRow = 0;
col = imageWidth - 1;
while ((col >= 0) && (0 == uncompactedData[dataBase + col]))
{
col--;
zerosAtEndOfRow++;
}
lineDataEnd = (short)((imageWidth - 1) - zerosAtEndOfRow);
if (lineDataStart == imageWidth)
{
// all zeros
// assign to table
ByteConversions.setShortInByteArrayAtPosition((short)-1, zeroCompressionTableData, tableBase + ZERO_COMPRESSION_LINE_DATA_START_BYTE_OFFSET);
ByteConversions.setShortInByteArrayAtPosition((short)-1, zeroCompressionTableData, tableBase + ZERO_COMPRESSION_LINE_DATA_END_BYTE_OFFSET);
ByteConversions.setIntegerInByteArrayAtPosition(0, zeroCompressionTableData, tableBase + ZERO_COMPRESSION_LINE_DATA_OFFSET_OFFSET);
}
else
{
// assign to table
ByteConversions.setShortInByteArrayAtPosition(lineDataStart, zeroCompressionTableData, tableBase + ZERO_COMPRESSION_LINE_DATA_START_BYTE_OFFSET);
ByteConversions.setShortInByteArrayAtPosition(lineDataEnd, zeroCompressionTableData, tableBase + ZERO_COMPRESSION_LINE_DATA_END_BYTE_OFFSET);
ByteConversions.setIntegerInByteArrayAtPosition(lineDataOffset, zeroCompressionTableData, tableBase + ZERO_COMPRESSION_LINE_DATA_OFFSET_OFFSET);
for (col = lineDataStart; col <= lineDataEnd; ++col)
pessimisticCompactedData[uncompactedByteArrayIndex++] = uncompactedData[dataBase + col];
}
lineDataOffset = uncompactedByteArrayIndex;
}
byte compactedData[] = new byte[uncompactedByteArrayIndex];
System.arraycopy(pessimisticCompactedData, 0, compactedData, 0, uncompactedByteArrayIndex);
return compactedData;
} |
5f55c135-b9d0-49a5-ab58-f31308844bbc | 9 | private void declaraVariavel(String tipo, String nome, String valor) {
Variavel var = null;
if (! existeVariavel(nome)) {
if (tipo.equals("inteiro")) {
var = new Inteiro(nome, valor.equals("") ? 0 : Integer.parseInt(valor));
} else if (tipo.equals("real")) {
var = new Real(nome, valor.equals("") ? 0.0 : Double.parseDouble(valor));
} else if (tipo.equals("caractere")) {
var = new Caractere(nome, valor != null && valor.length() > 1 ? valor.substring(1, valor.length() - 1) : "");
}
}
if (var != null) {
vars.add(var);
}
} |
aa5df587-af5a-4daa-8394-71ef7baa4d82 | 2 | public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int cases = input.nextInt();
for (int q = 0; q < cases; ++q) {
long p = input.nextInt();
int flips = 0;
while (!isPalindrome(p)) {
long r = reverse(p);
p += r;
++flips;
}
System.out.println(flips + " " + p);
}
} |
8349a631-8e7a-4ba6-af5f-aa6cee8ab0b2 | 8 | public void notifyObservers(Event event)
{
if(observers != null) {
synchronized (observers) {
if(!observers.isEmpty()) {
loopCounter++;
for(EventListener obs : observers) {
try {
obs.eventOccured(event);
}
catch(Error err) {
notifyFailure(err, obs);
}
catch(Exception exc) {
notifyFailure(exc, obs);
}
}
loopCounter--;
// do we have to delete an observer after the iteration?
if((loopCounter <= 0) && (observersDeletion != null)) {
//Logging.getInstance().trace(this, "Delayed removal of " +observersDeletion.size() +" observers");
for(EventListener obs : observersDeletion) {
observers.remove(obs);
}
observersDeletion = null;
}
} else {
storeEvent(event);
}
}
} else {
storeEvent(event);
}
} |
83d289a7-64c4-4e6c-b838-e404308fd950 | 0 | public Ball(int x, int y, int width, int height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
} |
5cc245b6-fa5d-4f56-801d-d9eefdc46804 | 9 | public KeyListenerEvent(){
Key = KeyType.NULL;
JFrame gui = new JFrame();
gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
gui.setTitle("Bomberman's KeyListenerEvent");
gui.setSize(700,200);
gui.setLocationRelativeTo(null);
DisplayKey = new JTextArea();
ReceiveKey = new JTextArea();
ReceiveKey.addKeyListener(new KeyListener(){
/**
* Method keyPressed define o swicth cases de cada
* butão e seu respectivo valor no teclado.
*/
@Override
public void keyPressed(KeyEvent e) {
switch(e.getKeyCode()){
case MOVE_UP_LEFT_HAND:
case MOVE_UP_RIGHT_HAND:
Key = KeyType.MOVE_UP;
break;
case MOVE_LEFT_LEFT_HAND:
case MOVE_LEFT_RIGHT_HAND:
Key = KeyType.MOVE_LEFT;
break;
case MOVE_DOWN_LEFT_HAND:
case MOVE_DOWN_RIGHT_HAND:
Key = KeyType.MOVE_DOWN;
break;
case MOVE_RIGHT_LEFT_HAND:
case MOVE_RIGHT_RIGHT_HAND:
Key = KeyType.MOVE_RIGHT;
break;
case DROP_BOMB_LEFT_HAND:
Key = KeyType.DROP_BOMB;
break;
default:
Key = KeyType.NULL;
}
getKey();
}
/**
* Method keyReleased retorna um valor NULL quando nenhuma tecla está pressionada
*/
@Override
public void keyReleased(KeyEvent e) {
Key = KeyType.NULL;
}
@Override
public void keyTyped(KeyEvent e) {
}
});
gui.add(ReceiveKey, BorderLayout.NORTH);
gui.add(DisplayKey, BorderLayout.CENTER);
gui.setVisible(true);
} |
21e4712e-1346-4bd5-8e72-cf7a36605754 | 8 | private static void makeTet5(SquareColor[][] tet) {
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
if ((i == 2 && j == 1) || (i == 3 && (j == 0 || j == 1 || j == 2))) {
tet[i][j] = SquareColor.BLUE;
} else tet[i][j] = null;
}
}
} |
2b62af37-059a-4abc-a91a-972891b6c52e | 0 | public TrackedPeer removePeer(String peerId) {
return this.peers.remove(peerId);
} |
01eaf70c-46bd-4bd3-91f6-3a17305b1839 | 5 | public void explosion(int x, int y, int hardness)
{
for (int xa = -(hardness / 2); xa <= (hardness / 2); xa++) {
for (int ya = -(hardness / 2); ya <= (hardness / 2); ya++) {
int distance = (int) Math.abs(Math.sqrt(xa*xa + ya*ya));
if (distance <= (hardness / 2)) {
Tile tile = setTile(x + xa, y + ya, Tile.air, true);
if (tile != null) tile.onExplosion(this, x + xa, y + ya, x, y);
}
}
}
for (Entity entity : entities) {
entity.onExplosion(x*16.0, y*16.0, hardness);
}
} |
38e454b3-7dfd-43f3-9bd5-bca043c01f9a | 7 | private final boolean cvc(int i) {
if (i < 2 || !cons(i) || cons(i - 1) || !cons(i - 2))
return false;
{
int ch = b[i];
if (ch == 'w' || ch == 'x' || ch == 'y')
return false;
}
return true;
} |
d4f49266-08b7-4942-b034-d0ed640f7d3c | 1 | public ContinuousUniform(double low, double high) throws ParameterException {
if (low >= high) {
throw new ParameterException("ContinuousUniform parameters low < high.");
} else {
this.low = low;
this.high = high;
this.rand = new Random();
}
} |
1d155e9e-47ee-43e7-a5af-35d2b9bf42e8 | 3 | public double interpolate(double xx){
double h=0.0D,b=0.0D,a=0.0D, yy=0.0D;
int k=0;
int klo=0;
int khi=this.nPoints-1;
while (khi-klo > 1){
k=(khi+klo) >> 1;
if(this.x[k] > xx){
khi=k;
}
else{
klo=k;
}
}
h=this.x[khi]-this.x[klo];
if (h == 0.0){
throw new IllegalArgumentException("Two values of x are identical: point "+klo+ " ("+this.x[klo]+") and point "+khi+ " ("+this.x[khi]+")" );
}
else{
a=(this.x[khi]-xx)/h;
b=(xx-this.x[klo])/h;
yy=a*this.y[klo]+b*this.y[khi]+((a*a*a-a)*this.d2ydx2[klo]+(b*b*b-b)*this.d2ydx2[khi])*(h*h)/6.0;
}
return yy;
} |
d1954f0b-be40-427e-81e5-3d825b967a0d | 5 | final public void partition(ParseList list) throws ParseException {
ParseArea area; ParseModifier modifier; ParseModifierGroup mGroup;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case AREA:
area = area();
partition(list);
list.addArea(area);
break;
case MODIFIER:
modifier = modifier();
partition(list);
list.addModifier(modifier);
break;
case MODIFIERGROUP:
mGroup = modifierGroup();
partition(list);
list.addModifierGroup(mGroup);
break;
case 0:
jj_consume_token(0);
break;
default:
jj_la1[0] = jj_gen;
jj_consume_token(-1);
throw new ParseException();
}
} |
42fa4a06-6092-4e8c-870e-195ad8a0f0f1 | 4 | public JSONWriter key(String string) throws JSONException {
if (string == null) {
throw new JSONException("Null key.");
}
if (this.mode == 'k') {
try {
this.stack[this.top - 1].putOnce(string, Boolean.TRUE);
if (this.comma) {
this.writer.write(',');
}
this.writer.write(JSONObject.quote(string));
this.writer.write(':');
this.comma = false;
this.mode = 'o';
return this;
} catch (IOException e) {
throw new JSONException(e);
}
}
throw new JSONException("Misplaced key.");
} |
e8cc1d38-1c89-4d95-9b46-9f732e3ad178 | 2 | public void printComponent(Graphics g) {
// boolean oldAdapt = adapt;
// adapt = true;
if (transformNeedsReform)
reformTransform(g.getClipBounds());
g.setColor(java.awt.Color.white);
g.fillRect(0, 0, g.getClipBounds().width, g.getClipBounds().height);
Graphics2D g2 = (Graphics2D) g;
g2.transform(transform);
drawer.invalidate();
drawer.drawAutomaton(g);
ArrayList notes = this.getDrawer().getAutomaton().getNotes();
for(int k = 0; k < notes.size(); k++){
Note curNote = (Note)notes.get(k);
curNote.updateView();
}
// adapt = oldAdapt;
// reformTransform(new Rectangle(getSize()));
} |
807893a7-c533-43ee-a6f9-628401040f42 | 8 | public double[][] string_to_double_array(String[] lines)
{
double[][] temp=null;
for(int i=0;i<lines.length;i++)
{
String[] part=lines[i].split(" ");
int c=0;
if(i==0)
{
c=0;
for(int j=0;j<part.length;j++)
{
if(part[j].length()>0&&is_numeric(part[j]))
{
c++;
}
}
temp=new double[lines.length][c];
c=0;
}
for(int j=0;j<part.length;j++)
{
if(part[j].length()>0&&is_numeric(part[j]))
{
temp[i][c++]=Double.parseDouble(part[j]);
}
}
}
return temp;
} |
1c8114d8-7ef6-484d-b2b8-6a9de4acae01 | 7 | public void updateAsScheduled(int numUpdates) {
super.updateAsScheduled(numUpdates) ;
checkMeltdownAdvance() ;
if (! structure.intact()) return ;
//
// Calculate output of power and consumption of fuel-
float fuelConsumed = 0.01f, powerOutput = 5 ;
fuelConsumed *= 2 / (2f + structure.upgradeLevel(WASTE_PROCESSING)) ;
powerOutput *= (2f + structure.upgradeLevel(FUSION_CONFINEMENT)) / 2 ;
if (stocks.amountOf(POWER) >= 50 + (powerOutput * 10)) {
fuelConsumed /= 10 ;
powerOutput = 0 ;
}
final Item fuel = Item.withAmount(FUEL_CORES, fuelConsumed) ;
if (stocks.hasItem(fuel)) stocks.removeItem(fuel) ;
else powerOutput /= 5 ;
stocks.bumpItem(POWER, powerOutput) ;
//
// Update demand for raw materials-
stocks.forceDemand(
FUEL_CORES, stocks.demandFor(POWER) / 5f,
VenueStocks.TIER_CONSUMER
) ;
if (structure.upgradeLevel(ISOTOPE_CONVERSION) > 0) {
stocks.translateDemands(1, METALS_TO_FUEL) ;
}
//
// If possible, assist in recovery of psi points-
final int PB = structure.upgradeLevel(QUALIA_WAVEFORM_INTERFACE) ;
final Actor ruler = base().ruler() ;
if (PB > 0 && ruler != null && ruler.aboard() instanceof Bastion) {
ruler.health.adjustPsy(PB / 100f) ;
}
//
// Output pollution-
int pollution = 10 ;
pollution -= structure.upgradeLevel(WASTE_PROCESSING) * 2 ;
pollution -= structure.upgradeLevel(FUSION_CONFINEMENT) ;
structure.setAmbienceVal(0 - pollution) ;
} |
fe018796-13d5-463a-adab-3744e4e14552 | 4 | public static void setTemplate(int template) throws UnsupportedLookAndFeelException, ClassNotFoundException, IllegalAccessException, InstantiationException, Exception {
UIManager.put("Menu.font", templateFont);
UIManager.put("MenuItem.font", templateFont);
UIManager.put("Button.font", templateFont);
UIManager.put("Label.font", templateFont);
UIManager.put("TextArea.font", templateFont);
if (template==Constant.SKINLF_TEMPLATE){
Skin skin = SkinLookAndFeel.loadThemePack("resource/lib/themepack.zip");
SkinLookAndFeel.setSkin(skin);
UIManager.setLookAndFeel(new SkinLookAndFeel());
}else if (template==Constant.METAL_TEMPLATE){
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
}
else if (template==Constant.MOTIF_TEMPLATE){
UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
}
else if (template==Constant.NIMBUS_TEMPLATE){
UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
}
} |
688c91bd-be4c-4fc3-9139-4e48f30fc703 | 0 | public Queue<RouterPacket>[] GetInputBuffer()
{
return inputBuffer;
} |
1d765466-e5f4-4d5c-9372-7962d98a0c93 | 8 | public static void createStDevStats1(int n, int k, String... files)
{
try
{
int line_number=0;
if(n==2)
line_number = Ngrams2_lineNumber;
else if(n==3)
line_number = Ngrams3_lineNumber;
else if(n==4)
line_number = Ngrams4_lineNumber;
else if(n==5)
line_number = Ngrams5_lineNumber;
if(files.length == 0)
return;
double sum = 0;
double stdDev[][];
ArrayList<Ngrams> main;
ArrayList<Ngrams>[] pool = (ArrayList<Ngrams>[])new ArrayList[files.length-1];
ArrayList<Ngrams> aux;
main = getFreqFromDBFile(n, files[0]);
for(int i=1; i<files.length; i++)
{
aux = getFreqFromDBFile(n, files[i]);
pool[i-1] = aux;
}
stdDev = getStdDev(line_number, k, pool);
for(int i=0; i<line_number; i++)
{
sum += Math.abs(((stdDev[i][0] + stdDev[i][1])/2) - main.get(i).freq);
}
System.out.printf("%.8f\n", sum);
}
catch(Exception e)
{
System.out.println(e);
}
} |
4d1890ea-068a-426a-83f2-c7a9b3c82796 | 9 | public void processQueries(String strInputFilePath, String strOutputFilePath)
throws IOException {
oBufferedReader = new BufferedReader(new FileReader(strInputFilePath));
oBufferedWriter = new BufferedWriter(new FileWriter(strOutputFilePath));
calcuateTFIDF(oBufferedReader);
oBufferedReader.close();
oBufferedReader = new BufferedReader(new FileReader(strInputFilePath));
String strLine = null;
String strNumber = null;
Hashtable<String, Double> oTempTermVsTFIDF = new Hashtable<String, Double>();
while ((strLine = oBufferedReader.readLine()) != null) {
if (strLine.trim().length() == 0)
continue;
if (strLine.trim().equalsIgnoreCase("</top>")) {
writeTermsToFile(strNumber, oTempTermVsTFIDF);
} else
if (strLine.trim().startsWith("<num>")) {
strNumber = strLine.substring(strLine.indexOf(":") + 1).trim();
} else if (strLine.trim().startsWith("<narr>")
|| !strLine.trim().startsWith("<"))
{
if (strLine.startsWith("<narr>"))
strLine = strLine.substring(7).trim().toLowerCase();
// ----
for (String strTerm : strLine.split(" ")) {
// ----
if (oTermVsTFIDF.containsKey(strTerm))
oTempTermVsTFIDF.put(strTerm, oTermVsTFIDF.get(strTerm));
}
}
}
//
// for (Entry<String, Double> entry : oTempTermVsTFIDF.entrySet()) {
// System.out.println("Key = " + entry.getKey() + ", Value = " + entry.getValue() + ", Terms = " + entry);
// }
System.out.println(oTempTermVsTFIDF);
oBufferedReader.close();
oBufferedWriter.close();
} |
1a6154f4-e1f8-4d43-a44a-ec6f9950a587 | 6 | public static Boolean isNullOrEmpty(Object object) {
if (object == null) {
return true;
} else {
if (object instanceof Collection) {
if (((Collection) object).isEmpty()) {
return true;
}
} else if (object instanceof AbstractMap) {
if (((AbstractMap) object).isEmpty()) {
return true;
}
} else {
if (object.toString().trim().equals("")) {
return true;
}
}
return false;
}
} |
f8fa1469-1b5c-4b79-b584-5ade5f47bb82 | 9 | private static Class<?> getVirtualMachineClass() throws ClassNotFoundException {
try {
return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
public Class<?> run() throws Exception {
try {
return ClassLoader.getSystemClassLoader().loadClass(VIRTUAL_MACHINE_CLASSNAME);
} catch (ClassNotFoundException cnfe) {
for (File jar : getPossibleToolsJars()) {
try {
Class<?> vmClass = new URLClassLoader(new URL[] { jar.toURL() }).loadClass(VIRTUAL_MACHINE_CLASSNAME);
LOGGER.info("Located valid 'tools.jar' at '{}'", jar);
return vmClass;
} catch (Throwable t) {
LOGGER.info("Exception while loading tools.jar from '{}': {}", jar, t);
}
}
throw new ClassNotFoundException(VIRTUAL_MACHINE_CLASSNAME);
}
}
});
} catch (PrivilegedActionException pae) {
Throwable actual = pae.getCause();
if (actual instanceof ClassNotFoundException) {
throw (ClassNotFoundException)actual;
}
throw new AssertionError("Unexpected checked exception : " + actual);
}
} |
d6363908-1bd0-4b23-ae61-4db9342ee881 | 3 | private void alarm() {
if (input.getAlarmFlag() && time == alarmTime) {
alarmCounter = 20;
}
if (alarmCounter > 0) {
alarmCounter -= 1;
output.doAlarm();
}
} |
25d77da6-9cba-4e15-9cf6-f5605244f9d6 | 0 | @Basic
@Column(name = "CTR_ESTADO")
public String getCtrEstado() {
return ctrEstado;
} |
a2598219-c1fe-4583-866d-5478670fb518 | 8 | static final void method165(int i, int i_6_, int i_7_, int i_8_, int i_9_,
int i_10_, int i_11_, byte i_12_, int i_13_,
int i_14_) {
anInt5194++;
if (i_9_ < 512 || i_11_ < 512
|| (i_9_ ^ 0xffffffff) < ((-2 + Class367_Sub4.mapSizeX) * 512
^ 0xffffffff)
|| (-2 + Class348_Sub40_Sub3.mapSizeY) * 512 < i_11_)
Class239_Sub21.anIntArray6062[0]
= Class239_Sub21.anIntArray6062[1] = -1;
else if (i_12_ >= 22) {
int i_15_ = Class275.method2064(i_9_, i, 11219, i_11_) - i_7_;
if (Class59_Sub1.aBoolean5300)
Queue.method1010(false, true);
else {
Class157.aClass101_2123.method891(i_10_, 0, 0);
Class348_Sub8.currentToolkit.method3638(Class157.aClass101_2123);
}
if (!Class305.aBoolean3870)
Class348_Sub8.currentToolkit.da(i_9_, i_15_, i_11_,
Class239_Sub21.anIntArray6062);
else
Class348_Sub8.currentToolkit.HA(i_9_, i_15_, i_11_,
Class132.anInt1906,
Class239_Sub21.anIntArray6062);
if (Class59_Sub1.aBoolean5300)
Class285_Sub1.method2129((byte) 60);
else {
Class157.aClass101_2123.method891(-i_10_, 0, 0);
Class348_Sub8.currentToolkit.method3638(Class157.aClass101_2123);
}
}
} |
a58155e0-e6e7-4124-8552-b2415fbd0788 | 8 | @EventHandler
public void onPull(PlayerInteractEvent e) {
Block b = e.getClickedBlock();
if(e.getAction() == Action.RIGHT_CLICK_BLOCK && b.getType() == Material.LEVER && SlotMachine.isSlotMachinePart(e.getClickedBlock())){
if(!e.getPlayer().hasPermission("slotmachines.use")) {
e.getPlayer().sendMessage(ChatColor.RED + "You do not have permission to use this slot machine.");
e.setCancelled(true);
return;
} else if(SlotMachineSequence.isRunning(b)) {
e.getPlayer().sendMessage(ChatColor.RED + "This slot machine is currently in use.");
e.setCancelled(true);
return;
}
if ((b.getState().getRawData() & 0x8) == 0) SlotMachineSequence.start(b,e.getPlayer());
}
if(e.getAction() == Action.LEFT_CLICK_BLOCK && selectingBlock.contains(e.getPlayer())) lastHitBlock.put(e.getPlayer(), e.getClickedBlock());
} |
5da21509-afff-4bc4-97f1-f917201520cc | 4 | public void generateDOT(){
try{
File file = new File("calls.dot");
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file);
BufferedWriter bw = new BufferedWriter(fw);
bw.write("digraph calls {\n");
System.out.println(calls.toString());
for (String s1 : calls.keySet()){
for (String s2 : calls.get(s1)){
bw.write(s1+" -> "+s2+";\n");
}
}
bw.write("}");
bw.close();fw.close();
}catch(IOException e) {
e.printStackTrace();
}
} |
38996486-9c88-4733-9ca1-e210dce60ccf | 6 | public void run() {
Actions.count = false;
System.out.println("СПИЧКИ:\n");
spichki = 15;
engine();
while (spichki > 0) {
if (!once) {
System.out.println("Для начала игры:\n" + "1) нажмите ENTER\n"
+ "2) введите от любое число и нажмите ENTER");
sc.next();
}
once = true;
playerMove();
engine();
if (spichki == 0) {
System.out.println("ВЫ ПРОИГРАЛИ!!! ПОБЕДИЛ РИДЖС!");
Actions.count = true;
once = false;
Checker.onCheck();
break;
}
System.out.println("Ходит Риджс...");
try {
Thread.sleep(1000);
} catch (Exception e) {
}
AILogic();
spichki -= compHod;
System.out.println("Компьютер взял " + compHod + " спич.");
if (spichki == 0) {
System.out.println("ВЫ ВЫИГРАЛИ!");
if (GlobalParams.FVQuestEpidemiaTraderRidjz == 1) {
GlobalParams.FVQuestEpidemiaScore += 1;
}
Actions.count = true;
once = false;
Checker.onCheck();
break;
}
engine();
System.out.println("Осталось " + spichki + " спич.");
}
spichki = 15;
} |
64fbc294-5c6c-4ac0-81d0-d6bd4f0765a3 | 4 | public V remove(K key) {
searchElement(key);
if (_searchHolder == null) {
return null; // Nothing was found
}
// Found a value
V value = _searchHolder.value;
// Deleting the entry
if (buckets.getElement(_searchBucketIndex).getSize() == 1) {
// Clear the whole bucket
buckets.setElement(_searchBucketIndex, null);
} else {
// Get rid of the element in the bucket array
buckets.getElement(_searchBucketIndex).removeAt(_searchInnerIndex);
}
--loadCounter;
if (loadCounter / primes[capacityIndex] >= 1 - loadFactor && capacityIndex > 0) {
rescale(--capacityIndex);
}
return value;
} |
25780ab9-9d3f-4067-b568-bb6c3fad2f84 | 3 | public String checkYourself(String stringGuess) {
int guess = Integer.parseInt(stringGuess);
String result = "miss";
for (int cell: locationCells)
{
if (guess == cell) {
result = "hit";
numOfHits++;
break;
}
}
if (numOfHits == locationCells.length)
{
result = "kill";
}
System.out.println(result);
return result;
} |
c62e7bbf-6e36-45aa-a0be-77e80857e364 | 1 | public void runGroups(boolean includeManual)
{
for(GroupSettings settings : getGroups(includeManual))
runGroup(settings, mNoisy, includeManual);
} |
90553ec8-1702-4af0-95e4-0fd4b1784d32 | 1 | public DecoderPanel(int usableSize, int random) {
super();
this.random = random;
int cipherPanelSize = 400;
int wrapamount = (usableSize / cipherPanelSize);
//set LayoutMng
this.setLayout(new MigLayout("wrap" + wrapamount, "[grow, center]", ""));
this.setBackground(Color.BLACK);
Border panelBorder = new EmptyBorder(0, 0, 0, 0);
this.setBorder(panelBorder);
int cipherPanelHeight = 130;
for(JPanel jPanel : CipherHandler.activeCiphers.values())
add(jPanel, "w " + cipherPanelSize + "!, h " + cipherPanelHeight + "!");
} |
a9947016-0126-4f5a-9420-015f66a1e829 | 3 | private static void calcNoOfNodes(Node node) {
if (node instanceof Parent) {
if (((Parent) node).getChildrenUnmodifiable().size() != 0) {
ObservableList<Node> tempChildren = ((Parent) node).getChildrenUnmodifiable();
noOfNodes += tempChildren.size();
for (Node n : tempChildren) {
calcNoOfNodes(n);
//System.out.println(n.getStyleClass().toString());
}
}
}
} |
ec9c7904-ca5d-4384-93c2-fb9b19debf9f | 9 | public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
Player player = (Player)sender;
ChatColor blue = ChatColor.AQUA;
ChatColor gold = ChatColor.GOLD;
ChatColor green = ChatColor.GREEN;
if(command.getName().equalsIgnoreCase("sm") && (player.isOp() || player.hasPermission("skeptermod.usecommand.sm") || player.getName().equals("Skepter")));
{
if((args.length == 0) || (args[0].equalsIgnoreCase("help")))
{
//Main command
player.sendMessage(gold + "[Skeptermod] " + blue + "---" + green + "Help Page" + blue + "---");
player.sendMessage(green + "Commands:");
player.sendMessage(green + "/sm info " + blue + "Displays information about the Skeptermod");
player.sendMessage(green + "/sm items " + blue + "Displays help about Skeptermod's items");
player.sendMessage(green + "/smrecipe help " + blue + "Displays Skeptermod item recipes");
player.sendMessage(green + "/sm changelog " + blue + "Displays Skeptermod's changelog");
player.sendMessage(green + "/smexplode " + blue + "Displays explosion commands");
player.sendMessage(green + "/smmob " + blue + "Displays mob commands");
player.sendMessage(green + "/smclear " + blue + "Clears all dropped items");
player.sendMessage(green + "/smlightning " + blue + "Creates lightning at that area");
player.sendMessage(green + "/smgive " + blue + "Gives Skeptermod items");
}
else if(args[0].equalsIgnoreCase("info"))
{
//Information
player.sendMessage(gold + "[Skeptermod] " + blue + "---" + green + "Information" + blue +"---");
player.sendMessage(blue + "Version: " + green + "[1.8]");
player.sendMessage(blue + "Author: " + green + "Skepter");
}
else if(args[0].equalsIgnoreCase("changelog"))
{
//Changelog
player.sendMessage(gold + "[Skeptermod] " + blue + "---" + green + "Changelog" + "---");
player.sendMessage(green + "[1.0]");
player.sendMessage(blue + "Official release");
player.sendMessage(blue + "Added witherbow, firebow, megadiamond");
player.sendMessage(green + "[1.1]");
player.sendMessage(blue + "Reduced megadiamond's power:");
player.sendMessage(blue + "Removed explosion, ghast sound and flame effect");
player.sendMessage(blue + "Fixed megadiamond inventory bug");
player.sendMessage(green + "[1.2]");
player.sendMessage(blue + "Added The Sword of the Gods");
player.sendMessage(blue + "Named all recipes");
player.sendMessage(green + "[1.2.1]");
player.sendMessage(blue + "Added lightning effect and full health effect to Sword of the Gods when used");
player.sendMessage(green + "[1.3]");
player.sendMessage(blue + "Added Healing Sword");
player.sendMessage(green + "[1.3.1]");
player.sendMessage(blue + "Added /skeptermod command");
player.sendMessage(green + "[1.4]");
player.sendMessage(blue + "Added /smexplode command");
player.sendMessage(blue + "Added Warhammer");
player.sendMessage(green + "[1.4.1]");
player.sendMessage(blue + "Bug fixes");
player.sendMessage(green + "[1.4.2]");
player.sendMessage(blue + "Added permissions");
player.sendMessage(blue + "Added health gain when you kill mobs/players");
player.sendMessage(green + "[1.5 - command update]");
player.sendMessage(blue + "Mass code cleanup");
player.sendMessage(blue + "Added any value for /smexplode");
player.sendMessage(blue + "Added /smlightning command");
player.sendMessage(blue + "Added /smclear command");
player.sendMessage(blue + "Added Chaos emerald");
player.sendMessage(blue + "Improved Megadiamond: Now called 'Diamond of Destiny', easier to craft and has multiple powers");
player.sendMessage(green + "[1.6 - emerald update]");
player.sendMessage(blue + "Added Mobs");
player.sendMessage(blue + "Added /Skeptermod items command");
player.sendMessage(blue + "Added HyperSpeed Emerald, Lightning Emerald and Chimera Emerald");
player.sendMessage(blue + "Added /Skeptermod recipes help command");
player.sendMessage(green + "[1.7 - give update]");
player.sendMessage(blue + "Added /sm Give command to give items");
player.sendMessage(blue + "Fixed bug regarding to bows not being able to fire");
player.sendMessage(green + "[1.7.1]");
player.sendMessage(blue + "Fixed /smgive command");
player.sendMessage(green + "[1.7.2]");
player.sendMessage(blue + "Increased HyperSpeedChaos Emerald to 5 seconds instead of 1");
player.sendMessage(blue + "Tweaked Chaos Emerald Recipe for easier use");
player.sendMessage(green + "[1.7.3]");
player.sendMessage(blue + "Added Potato Skeleton mob");
player.sendMessage(blue + "Fixed bug where mobs spawn in the ground");
player.sendMessage(green + "[1.7.4]");
player.sendMessage(blue + "Allowed user to spawn multiple mobs by adding a number");
player.sendMessage(blue + "Fixed coloring bug");
player.sendMessage(green + "[1.7.5]");
player.sendMessage(blue + "Ajusted /smlightning command to spawn your defined amount of bolts");
player.sendMessage(blue + "Tweaked limits on mob and lightning amounts");
player.sendMessage(blue + "Ajusted recipes for bows");
player.sendMessage(blue + "Allowed user to give a certain amount of items with /smgive");
player.sendMessage(blue + "Ajusted /sm recipe command to /smrecipe");
player.sendMessage(green + "[1.7.6]");
player.sendMessage(blue + "Fixed bug with /smgive command");
player.sendMessage(green + "[1.7.7]");
player.sendMessage(blue + "Added radius input for /smlightning command");
player.sendMessage(green + "[1.8]");
player.sendMessage(blue + "Added The Sword from Hell");
player.sendMessage(blue + "Godsword now extinguishes player from fire");
}
else if(args[0].equalsIgnoreCase("items"))
{
//Item help
player.sendMessage(gold + "[Skeptermod] " + blue + "---" + green + "Item Help" + blue +"---");
player.sendMessage(green + "Witherbow " + blue + "Bow which fires wither heads");
player.sendMessage(green + "Firebow " + blue + "Bow which fires fireballs");
player.sendMessage(green + "Diamond of Destiny " + blue + "Diamond which has many features when you right click");
player.sendMessage(green + "Sword of the Gods " + blue + "Instant hit kill, regens health, strikes lightning");
player.sendMessage(green + "Healing Sword " + blue + "Sword which heals you when you right click");
player.sendMessage(green + "Warhammer " + blue + "Hammer which causes mass destruction and damage with right click");
player.sendMessage(green + "Chaos Emerald " + blue + "Activates Chaos mode when you right click with all 7");
player.sendMessage(green + "HyperSpeed Chaos Emerald " + blue + "Temporarily move 20 times faster when you right click");
player.sendMessage(green + "Chimera Chaos Emerald " + blue + "Teleports to where you look at when you right click");
player.sendMessage(green + "Lightning Chaos Emerald " + blue + "Creates 5 lightning strikes to where you look at when you right click");
player.sendMessage(green + "The Sword from Hell " + blue + "A sword weilding such power, has to have a disadvantage");
}
}
return true;
} |
a5ac8d1c-7ad9-458a-b0de-fa0a2fae5e0d | 4 | public void update(Vector3f plr) // Aux Thread
{
chunksLoaded = 0;
Chunk.updatePlrPos(plr);
playerPos = plr;
for(int i = (int)plr.x / Chunk.size - viewRange; i < (int)plr.x / Chunk.size + viewRange; i++)
for(int j = (int)plr.z/ Chunk.size - viewRange; j < (int)plr.z/ Chunk.size + viewRange; j++)
if(withinRange(plr.x, plr.z, i * Chunk.size, j * Chunk.size))
if(getChunk(i * Chunk.size, j * Chunk.size) == null)
loadChunk(i, j);
} |
1ca5cbcf-750e-46ad-a9d9-e9ffbd0ec118 | 2 | private static Map<String, String> getCurlParams(Node db) {
try {
ConfigParser cp = ConfigParser.getParser(db);
HashMap<String, String> ret = new HashMap<String, String>();
try {
ret.put("curl-url", cp.getElementAt("curl-url", 0)
.getAttribute("url"));
} catch (Exception e) {
cp.setNode((Element) db);
ret.put("curl-url", cp.getElementAt("endpoint", 0)
.getAttribute("uri"));
}
cp.setNode((Element) db);
ret.put("curl-update", cp.getElementAt("curl-update", 0)
.getAttribute("command"));
cp.setNode((Element) db);
ret.put("curl-drop",
cp.getElementAt("curl-drop", 0).getAttribute("command"));
cp.setNode((Element) db);
ret.put("curl-command", cp.getElementAt("curl-command", 0)
.getAttribute("command"));
cp.setNode((Element) db);
return ret;
} catch (ParserConfigurationException | SAXException | IOException e) {
LogHandler.writeStackTrace(Logger.getGlobal(), e, Level.SEVERE);
return null;
}
} |
fcd5dedf-4d3b-41f1-871e-b264733b4065 | 1 | public int lookAhead() throws IOException {
if (lookaheadChar == UNDEFINED) {
lookaheadChar = super.read();
}
return lookaheadChar;
} |
bc2ddd35-be52-475c-83ee-bb7d9d632d8a | 3 | public static Host deserializeHost(PeerReference peer) {
if (peer == null) {
throw new NullPointerException("Cannot transform a null value to a Host object");
}
Host host = null;
try {
host = new PGridHost(peer.address, peer.port);
host.setHostPath(peer.path);
if (peer.timestamp > 0) {
host.setTimestamp(peer.timestamp - 1); // based on how Lamport clock works
}
host.setUUID(UUID.fromString(peer.uuid));
} catch (UnknownHostException e) {
// Serialization guarantees that valid hosts will be deserialized.
}
return host;
} |
c8784a8c-ffed-4569-aa01-d567b48050ca | 0 | public void setDefault_(String default_) {
this.default_ = default_;
} |
f5be8f74-5f6e-4928-8ed4-d91e26d23ba7 | 2 | private void drawSecondSelectedCase(Graphics g) {
if (swappedI != -1 && swappedJ != -1) {
g.setColor(Color.YELLOW);
g.fillRect(swappedI * caseWidth + 1, swappedJ * caseHeight + 1,
caseWidth - 1, caseHeight - 1);
}
} |
d3dbe74e-b5d7-4a13-a83f-34a734272079 | 8 | public T deleteMin() {
int currentSize = heap.size() - 1;
if (currentSize == 0) {
return null;
}
// СԪ
T x = heap.get(1);
// һԪ
T y = heap.remove(currentSize);
// عӸʼΪyѰҺʵλ
// ѵĵǰڵ
int i = 1;
// iĺ
int ci = 2;
currentSize = heap.size() - 1;
try {
Class<?> c = y.getClass();
Method m = c.getMethod("compareTo", c);
while (ci <= currentSize) {
// ciӦiĽС
if (ci < currentSize
&& (Integer) m.invoke(heap.get(ci), heap.get(ci + 1)) > 0)
ci++;
// ܰyiλô
if ((Integer) m.invoke(y, heap.get(ci)) <= 0)
break;//
// ܣ
heap.set(i, heap.get(ci));
// һ
i = ci;
ci *= 2;
}
} catch (Exception e) {
e.printStackTrace();
}
if (currentSize >= i)
heap.set(i, y);
return x;
} |
f506d9f4-2330-4e66-b180-510b67459b15 | 5 | @Override
public String toString() {
// 現在の盤情報を文字列で取得する
StringBuilder sb = new StringBuilder();
sb.append(" 01234567\r\n");
Pos workPos = new Pos();
for (int y = Common.Y_MIN_LEN; y < Common.Y_MAX_LEN; y++) {
workPos.setY(y);
sb.append(y+" ");
for (int x = Common.X_MIN_LEN; x < Common.X_MAX_LEN; x++) {
workPos.setX(x);
switch (getColor(workPos)) {
case NONE:
sb.append(" ");
break;
case BLACK:
sb.append("●");
break;
case WHITE:
sb.append("○");
break;
}
sb.append("");
}
sb.append("\r\n");
}
return sb.toString();
} |
18adf882-bd51-428b-8254-fab6a3d2aec9 | 2 | public void copyRegionVFlip(CPRect r, CPLayer source) {
CPRect rect = new CPRect(0, 0, width, height);
rect.clip(r);
for (int j = rect.top, s = rect.bottom - 1; j < rect.bottom; j++, s--) {
for (int i = rect.left; i < rect.right; i++) {
data[i + j * width] = source.data[i + s * width];
}
}
} |
c05b7e31-7921-4370-9f64-d6f2de7ad6d7 | 3 | @Override
public boolean gainPassage(Oergi oergi) {
Element element = oergi.getElement();
ElementMovability elementMovability = new ElementMovability();
Movability movability = elementMovability.getMovability(this.getBiotype(), element);
if (movability == Movability.NO) {
return false;
}
else if (movability == Movability.LIMITED) {
if (this.getBiotype() == Biotype.TREE) {
return false;
}
else {
return true;
}
}
else {
return true;
}
} |
bd7253f0-8923-4cb0-aa1b-7ea99c4b25e4 | 9 | public List<String> createReversePolishExpression(String subStr) {
// 正实数的正则表达式;
String regex = "\\d+\\.{0,1}\\d*";
// 将匹配的正实数保存在字符串数组numbers中;
String[] numbers = matcher(regex, subStr);
String changeStr = subStr.replaceAll(regex, "0")
.replaceAll("E\\-0", "E1").replaceAll("\\^\\-0", "^1")
.replaceAll("\\s\\-0", "s1").replaceAll("\\c\\-0", "c1")
.replaceAll("\\t\\-0", "t1").replaceAll("i\\-0", "i1")
.replaceAll("o\\-0", "o1").replaceAll("\\a\\-0", "a1")
.replaceAll("\\e\\-0", "e1").replaceAll("\\n\\-0", "-1")
.replaceAll("m\\-0", "-1").replaceAll("q\\-0", "-1")
.replaceAll("\\-\\-0", "-1").replaceAll("\\+\\-0", "+1")
.replaceAll("\\*\\-0", "*1").replaceAll("\\/\\-0", "/1");
char[] chars = changeStr.toCharArray();
int index = 0;
List<String> list = new ArrayList<String>();
for (int i = 0; i < chars.length; i++) {
String str = String.valueOf(chars[i]);
if ("0".equals(str)) {
list.add(numbers[index++]);
} else if ("1".equals(str)) {
list.add("-" + numbers[index++]);
} else {
list.add(str);
}
}
List<String> suffix = new ArrayList<String>();
Stack<String> operator = new Stack<String>();
for (int i = 0; i < list.size(); i++) {
if (!isOperatorType(list.get(i))) {
suffix.add(list.get(i));
} else {
if (operator.count == 0) {
operator.push(list.get(i));
} else {
while (operator.count != 0
&& compare(operator.peek(), list.get(i)) >= 0) {
String top = operator.pop();
suffix.add(top);
}
operator.push(list.get(i));
}
}
}
while (operator.count != 0) {
suffix.add(operator.pop());
}
return suffix;
} |
d84c4d59-0ebc-4520-b8ec-716b9e1807e7 | 6 | private void setupBlock() throws IOException {
if (this.data == null) {
return;
}
final int[] cftab = this.data.cftab;
final int[] tt = this.data.initTT(this.last + 1);
final byte[] ll8 = this.data.ll8;
cftab[0] = 0;
System.arraycopy(this.data.unzftab, 0, cftab, 1, 256);
for (int i = 1, c = cftab[0]; i <= 256; i++) {
c += cftab[i];
cftab[i] = c;
}
for (int i = 0, lastShadow = this.last; i <= lastShadow; i++) {
tt[cftab[ll8[i] & 0xff]++] = i;
}
if ((this.origPtr < 0) || (this.origPtr >= tt.length)) {
throw new IOException("stream corrupted");
}
this.su_tPos = tt[this.origPtr];
this.su_count = 0;
this.su_i2 = 0;
this.su_ch2 = 256; /* not a char and not EOF */
if (this.blockRandomised) {
this.su_rNToGo = 0;
this.su_rTPos = 0;
setupRandPartA();
} else {
setupNoRandPartA();
}
} |
4fd360d3-0d91-434b-a337-0ea78a8eea83 | 5 | @Override
public Object getValueAt(int row, int column) {
Consulta m = linhas.get(row);
if (column == COL_ID) {
return m.getCodigo();
} else if (column == COL_HORA) {
return m.getHorario();
} else if (column == COL_DATA) {
return m.getDataDaConsulta();
} else if (column == COL_NOME) {
return m.getPaciente().getNome();
} else if (column == COL_TIPO) {
return m.getTipoConsulta();
}
return "";
} |
Subsets and Splits