method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
43340038-ec5a-494f-809f-d34e94523642 | 1 | public static String simplifyText(String line) {
String reformatted = line.toLowerCase().replaceAll(",", "")
.replaceAll("[^A-Za-z]", " ");
while (reformatted.contains(" ")) {
reformatted = reformatted.replaceAll(" ", " ");
}
return reformatted;
} |
ef50e2e1-6cff-4cc1-a90a-cec109fe5a3f | 0 | public void setDatetime(String datetime) {
this.datetime = datetime;
} |
94e8090b-46ab-4a30-9697-82cf63a9c9fd | 1 | public static void addErrorMessages(List<String> messages) {
for (String message : messages) {
addErrorMessage(message);
}
} |
af6e570b-b4d4-4e67-af85-c6f6b7b5cebf | 0 | public static Date getFirstDayOfTheMonth(Date date) {
String value = date2String(date, "yyyy-MM-01 00:00:00");
return string2Date(value);
} |
3b97faad-d5e7-4998-bf80-dc838bad08df | 1 | public StructuredBlock[] getSubBlocks() {
return (elseBlock == null) ? new StructuredBlock[] { thenBlock }
: new StructuredBlock[] { thenBlock, elseBlock };
} |
d1000571-dc97-4185-b6b7-6351f1d6cd48 | 9 | private void buildForStringFeature(TeaClassifier tc, TeaNode parent, String[] valueCombo, int level, List<Integer> usedAttributes, double sugar, String val, int index) {
String[] newValueCombo = new String[2];
newValueCombo[0] = valueCombo[0];
newValueCombo[1] = valueCombo[1];
List<Integer> newUsed = new ArrayL... |
9c69b791-1528-4d8d-8ad3-a0234e302dce | 3 | @Override
protected void onTextMessage(CharBuffer text) throws IOException {
Message message = new Message(text.toString());
RoboBase robo_base = RoboBase.getInstance();
String status;
switch (message.getCommand()) {
case LOGIN:
if (robo_base.login(message.getRobotName(), this)) {
status = "ok";
... |
e83b0226-43f5-4fc2-a25d-9202914056d4 | 9 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EquipmentType other = (EquipmentType) obj;
if (compatibleEquipment == null) {
... |
eb9c0756-8e44-4300-85e5-6b6b9935e917 | 2 | private String readURL(String descriptionAPI) {
try {
String urlResponse = "";
URLConnection connection = new URL(descriptionAPI).openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Ge... |
f0c94edd-0a6b-493e-8284-9d56980dd72c | 9 | @SuppressWarnings("serial")
public SchemaEditorMenuBar(final BasicGraphEditor editor)
{
final mxGraphComponent graphComponent = editor.getGraphComponent();
final mxGraph graph = graphComponent.getGraph();
JMenu menu = null;
JMenu submenu = null;
// Creates the file menu
menu = add(new JMenu(mxResources.g... |
5cbe22ac-592f-408d-b2da-a07b60f4327a | 5 | protected void handleGet(HttpRequest request) throws IOException {
String path = request.getRelativePath();
File file = new File(wwwRoot, path);
if (!file.exists()) {
String data = "<html><body>Not found</body></html>";
sendResponse(HTTP_STATUS.HTTP_FILE_NOT_FOUND, MIME.H... |
2d0659ac-ab7f-47d3-a3df-59293aa29cad | 9 | public boolean isScramble_recursive(String s1, String s2) {
if (s1 == null || s2 == null)
return false;
if (s1.length() != s2.length())
return false;
if (s1.equals(s2))
return true;
int len = s1.length();
for (int i = 1; i < len; i++) {
if (isS... |
4b4784d9-9225-404c-8706-7a138963a253 | 2 | public static void main(String[] args) {
if (args.length > 0) {
if (args[0].equalsIgnoreCase("-nogui")) {
instance = new PermWriter(false);
return;
}
}
instance = new PermWriter(true);
} |
194d6180-09c7-4a25-a3b7-cfbf73ac8c79 | 5 | private void processDataFrame(int channelPtr,
int ctype,
int flag,
ByteBuffer data) {
Channel channel;
ByteBuffer datac;
Iterator<Channel> it;
int size;
if (data == null || data... |
db3b0807-e773-4b0d-b811-b44ed49176c9 | 5 | private void crearTablero(){
Casilla c;
for(int fila=0;fila<TAMANYO;fila++){
for(int columna=0;columna<TAMANYO;columna++){
if (fila %2 ==0){
if (columna %2==0){
c= new Casilla(false);
casillas.add(c);
panelTablero.add(c);
}else{
c= new Casilla(true);
casillas.add(c);// casilla ne... |
048152bd-de2f-4c1d-95e0-8a6cddc7ed24 | 6 | public int checkAnswers(int week, User user, ArrayList<Integer> userAnswers) {
int score = 0;
PreparedStatement answerStatement = null;
PreparedStatement questionStatement = null;
Connection connection = null;
try {
try {
connection = data.getConnection();
... |
9d0b1017-0728-42d3-8279-cae65c9a4b5a | 2 | public void guardarCompraDOM(String rutaFichero, LinkedHashMap<Integer, Compra> compras) {
rutaFichero = rutaFichero + ".xml";
try {
DocumentBuilderFactory documentFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder documentBuilder = documentFactory.newDocumentBuilder... |
ba728625-a2aa-4166-93cb-9b402cd812bc | 9 | double calculatescore() {
total = 0;
for (int i = 0; i < seedlist.size(); i++) {
double score;
double chance = 0.0;
double totaldis = 0.0;
double difdis = 0.0;
for (int j = 0; j < seedlist.size(); j++) {
if (j != i) {
totaldis = totaldis
+ Math.pow(
distanceseed(seedlist.g... |
97aac98e-cca9-4b9e-b6e9-d7572068e026 | 0 | public void setComment(String comment) {
this.comment = comment;
} |
42eec921-fd15-494a-a59a-7a62fecbe7b2 | 7 | @Override
public void commandReceived(Object command) {
Command message = (Command) command;
String action = message.getCommand();
if (action.equals("clear_selection")) {
selectedCard = null;
} else if (action.equals("select_card")) {
selectedCard = (RedCard)message.getBaggage();
} else if (action.equa... |
959b4aff-0170-4f22-8f5f-cea7b8110d9a | 3 | public int getNeighboursNumberConnection(Node n)
{
int counter = 0;
ArrayList<Node> n_neighbours;
ArrayList<Node> t_neighbours;
n_neighbours = n.getToNode();
for(Node t : n_neighbours )
{
t_neighbours = t.getToNode();
for(int i=0;i<t_neighbours.size();i++)
{
Node current = t_neighbours... |
9f139403-d995-4fb0-a4cf-6dcd361e26e2 | 5 | private void findExactNN(Node node, ResultSet resultSet, double[] query) {
// Pruning. Ignore those clusters that are too far away -----
double bsq = metric.distance(query, node.pivot);
double rsq = node.radius;
double wsq = resultSet.worstDistance();
double val = bsq - rsq - wsq;
double val2 = val * val -... |
814b013e-b0b6-4fe2-99b2-e07297303835 | 5 | public void setIndividualArgs(String[] args) {
boolean startReadHypothesis = false;
StringBuffer tmpGoal = new StringBuffer();
StringBuffer tmpHypothesis = new StringBuffer();
try {
expressionName = args[indExpressionName];
moduleName = args[indModuleName];
modulePath = args[indModulePath];
componen... |
4f5a6fbc-4ada-416a-9116-3ec3bdad71c7 | 6 | public AttributeValue getValueAsObject() {
try {
if(this.getType().equals(StringAttribute.identifierURI.toString())) {
return StringAttribute.getInstance(getValue());
} else if(this.getType().equals(IntegerAttribute.identifierURI.toString())) {
return IntegerAttribute.getInstance(getValue());
} else ... |
303c981f-63dc-4c0d-9375-8850eb2065b9 | 5 | private static int subsequentCoins(int[][] board, int x, int y, int dx, int dy, int playerID) {
int newX = x + dx;
int newY = y + dy;
if ((newX >= 0 && newX < board.length) && (newY >= 0 && newY < board[0].length) && board[newX][newY] == playerID) {
return 1 + subsequentCoins(board, ... |
a74c297b-f195-4070-97aa-8721015ea09c | 4 | public Block[][] SplitChanneal(byte[][] _graph, int _y, int _x)
{
if((_x % 8 != 0) || (_y % 8 != 0)){
System.err.println("[ERROR] Input data should begins on a multiple of 8!");
return null;
}
// number of blocks
int _yBlock = _y/8;
int _xBlock = _x/8... |
8fbda629-48e9-4838-9ec5-f2c162ed215e | 4 | public static Frame getTopFrame(Container c)
{
if (c instanceof Frame)
return (Frame)c;
Container theFrame = c;
do {
theFrame = theFrame.getParent();
} while ((theFrame != null) && !(theFrame instanceof Frame));
if (theFrame == null)
... |
f3c80744-2def-4c13-b4f0-b95cd01dac76 | 0 | @Column(name = "PEP_MOA_CONSEC")
@Id
public int getPepMoaConsec() {
return pepMoaConsec;
} |
9e0cdb5b-c601-4a55-a18e-89b3aefb8c40 | 9 | private String getDescriptionFromSoundfileName(String soundfileName)
{
logger.logDebug("ENTERED makeDescriptionFromFilename ...");
// some self-protection
if (soundfileName == null)
return "";
if (soundfileName.trim().equals(""))
return "";
logger.logDebug("sound filename init: " + s... |
0943f829-80b2-40cd-bd54-f28cee7e4bee | 6 | private void processTransaction(){
EnumAction action = mActions.get(0).action;
mActions.remove(0);
if (action == EnumAction.Deposit){
mPerson.addCash(mTransactionAmount);
}
else if (action == EnumAction.Loan){
if (mTransactionAmount == 0){
//Rejected loan
//Non-normative
}
else{
mPerso... |
6ae93a1d-7d38-48b8-8346-65e1042ba50f | 2 | public double standardError_of_ComplexRealParts() {
boolean hold = Stat.nFactorOptionS;
if (nFactorReset) {
if (nFactorOptionI) {
Stat.nFactorOptionS = true;
} else {
Stat.nFactorOptionS = false;
}
}
double[] re = this.array_as_real_part_of_Complex();
double standardError = Stat.standardError... |
2778f7f3-db0a-4297-9ec5-eb496191c386 | 8 | public void tick(){
if(y + ny >= 0 && y + ny <= maxY - height){
y += ny;
}else{
ny *= -1;
y += ny;
}
if(x + nx >= 0 && x + nx <= maxX -width){
x += nx;
}else{
nx *=-1;
x += nx;
}
if(x <= 0){
x = 0;
}
if(x >= maxX -width){
x = maxX -width;
}
if(y >= maxY -height){
y = max... |
80a19b2d-7687-47f7-91c1-4d9030aa18c2 | 8 | @SuppressWarnings("deprecation")
private boolean viewChestFor(Player player, String[] strings) {
if (player.getTargetBlock(null, 50).getType() == Material.CHEST) {
Chest chest = (Chest) player.getTargetBlock(null, 50).getState();
if (strings.length == 0) {
if (methods.isSingleChest(chest) || chest instance... |
58aa79a8-0a52-4991-8d0b-15eadb16ffc2 | 4 | public static void sort(int[] array, int max) {
printArray(array);
int n = array.length;
int[] result = new int[array.length];
int[] count = new int[max + 1]; //辅助数组 count[i]存放array中小于或等于i的个数
for(int i = 0; i <= max; i++) { //辅助数组清0
count[i] = 0;
}
for (int i = 0; i < n; i++) { //将数值序... |
4c785989-0a15-484b-ab31-62b50c9b52b7 | 5 | @SuppressWarnings("deprecation")
public Restriction getRestriction(ItemStack item) {
int dataValue = item.getDurability();
if (shouldIgnoreDataValue(item) || item.getDurability() == 0) {
dataValue = -1;
}
for (Restriction r : this.restrictions) {
if (r.getItemID() != item.getTypeId())
continue;
... |
2efaaac1-54e0-4ed6-a24d-50443556c4a5 | 2 | public boolean viitoset(){
for(int i=0; i<5; i++){
if(nopat[i].getValue()==5){
return true;
}
}
return false;
} |
8e19af85-2332-40a4-a48c-325bdce32508 | 1 | public void testConstructor_RI_RI7() throws Throwable {
DateTime dt1 = new DateTime(2005, 7, 10, 1, 1, 1, 1);
DateTime dt2 = new DateTime(2004, 6, 9, 0, 0, 0, 0);
try {
new Interval(dt1, dt2);
fail();
} catch (IllegalArgumentException ex) {}
} |
b095473f-0bb8-42c5-84ac-15785c7602c4 | 3 | private void moveIncomingArcs( Node from, Node to ) throws MVDException
{
while ( !from.isIncomingEmpty() )
{
Arc a = from.removeIncoming( 0 );
to.addIncoming( a );
}
// check if node is now isolated
if ( from.indegree()==0&&from.outdegree()==0 )
from.moveMatches( to );
} |
6b221208-25d1-4ccd-a1d8-c6f870525419 | 6 | public static void main(String[] args) {
int BYTES_PER_LINE = 16;
if (args.length == 1) {
BYTES_PER_LINE = Integer.parseInt(args[0]);
}
int i;
for (i = 0; !BinaryStdIn.isEmpty(); i++) {
if (BYTES_PER_LINE == 0) { BinaryStdIn.readChar(); continue; }
... |
c38b3a41-b380-49dd-b0cf-0950bb2e5631 | 6 | private IMac getMac(char[] password) throws MalformedKeyringException {
if (!properties.containsKey("salt")) {
throw new MalformedKeyringException("no salt");
}
byte[] salt = Util.toBytesFromString(properties.get("salt"));
IMac mac = MacFactory.getInstance(properties.get("mac"));
... |
b77f7348-0c72-4130-9892-adeaa1723013 | 2 | public static void createGUI(){
gui = new GUI();
gui.setVisible(true);
//check if a properties file exists and load its values
if (PropertiesHandler.PropertiesFileExists()){
//read properties file
Properties prop = PropertiesHandler.readPropertiesFile();
... |
935d1d9e-7287-4ec1-a481-8d5cbe7762c3 | 3 | public Key delete(int i)
{
if (i > heap.length - 1 || i < 1)
return null;
Key key = heap[i];
heap[i] = heap[N--];
if (greater(heap[i], key))
sink(i);
else
swim(i);
return key;
} |
9569776e-da67-4abd-97b1-223ddc96ae04 | 0 | @Override
protected void setColoredExes() {
// TODO Auto-generated method stub
coloredEx = ParabolaGenerator.parabola(begin, p, size);
} |
2d59b8a5-71ac-40d1-a0ac-aaa00069e0be | 2 | private static void createInputMonitorThread(final InputStream in,final OutputStream out) {
// 消息广播线程
Runnable writeDistributeRunner = new Runnable(){
public void run(){
try{
startReceiveMessage(in);
}catch(Exception e){
e.printStackTrace();
}
}
};
Runnable sendRunner = new Run... |
a4fdd5c9-b43e-464f-a34f-db3d8bc29c53 | 9 | public void onAction(String binding, boolean value, float tpf) {
int relvel = this.muzzle_velocity;
if (binding.equals("shoot") && !value && this.app.begin ) {
Geometry bulletg = new Geometry("bullet", bullet);
bulletg.setMaterial(mat2)... |
711b63ab-e21a-48f5-9d1e-e5e4d281f4f7 | 7 | public static String getFeature(String line) throws IOException {
BufferedReader br = new BufferedReader(new FileReader(
Parameters.searchQuery));
Map<String, Integer> queryVector = new HashMap<String, Integer>();
String query = "";
while ((query = br.readLine()) != null) {
Matcher m = Pattern.compil... |
4d874261-0691-42a5-a770-162c8cafbdb2 | 3 | public void deleteSocket(MultipleTalkServer server, String ip){
try {
for (int i=0; i < server.socket.size()-1; i++){
if(ip.equals(server.socket.get(i).getName())){
server.socket.get(i).close();
server.socket.remove(i);
}
... |
28d9a43f-faa6-4600-b501-e41388140660 | 6 | public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof UnaryRule)) return false;
final UnaryRule unaryRule = (UnaryRule) o;
if (child != null ? !child.equals(unaryRule.child) : unaryRule.child != null) return false;
if (parent != null ? !parent.equals(unaryRule.... |
f28c6292-e11d-416a-b04b-00c45eb94e4b | 5 | private boolean chevauchement(Pair<Calendar, Calendar> firstPlage, Pair<Calendar, Calendar> secondPlage)
{
boolean heurDebDansIntervalle= firstPlage.getFirst().before(secondPlage.getFirst()) && secondPlage.getFirst().before(firstPlage.getSecond());
boolean heureFinDansIntervalle= firstPlage.getFirst().before(seco... |
04ec6a46-cd8c-4d41-8093-d18fa976b9c6 | 8 | public static void setup(Menus menu){
RiftFrame.menuControl = false;
if(menu.dialog == false){
RiftFrame.menuControl = true;
for(int a=0;a<menu.options[0];a++){
temp = new Sprite(ImageLibrary.voidBall, 0,0); //refreshes the variable so it does rewrite previous image
textTemp = new TextPoint... |
6edad5aa-8425-4a39-b275-6b80c6c33ce5 | 8 | public void removeElement(Object obj) throws QueueClosedException {
Element el, tmp_el;
if(obj == null)
return;
synchronized(mutex) {
if(closed) /*check to see if the queue is closed*/
throw new QueueClosedException();
el=head;
... |
671ca83b-4043-4133-b645-04a95517f2b4 | 3 | @Override
public void execute() {
try {
Scanner in = new Scanner(input);
while (in.hasNextLine()) {
String command = in.nextLine();
Iterable<String> array = Splitter.on(';').omitEmptyStrings().split(command);
Iterator itr = array.iterat... |
1e2f27eb-5c47-4bbc-ac4b-3912447e549c | 1 | public void returnOperation(final AbstractInsnNode insn, final Value value,
final Value expected) throws AnalyzerException {
if (!isSubTypeOf(value, expected)) {
throw new AnalyzerException(insn, "Incompatible return type",
expected, value);
}
} |
22d0e4d2-3ac3-4ea6-accc-b671105641d9 | 9 | private boolean diagonalDecrementingAttack(int[][] grid, LinkedList<Square> squareStore, boolean pickOne) {
//Attack - Diagonal dec
if ((grid[0][0] == 2 && grid[1][1] == 2) && grid[2][2] != 1) {
BuildAndAddSquareTwoTwo(squareStore);
pickOne = updateGridTwoTwo(grid);
} els... |
97fbb9f4-78b6-40df-b57a-c26d222ae56d | 5 | public void start(String[] args){
try{
if(args.length == 0){
processDirectoryTree(new File("."));
}
else{
for(String arg:args){
File fileArg = new File(arg);
if(fileArg.isDirectory()){
processDirectoryTree(fileArg);
}
else{
if(!arg.endsWith("."+ext)){
arg += "."... |
0b469537-466e-4fba-852b-5473103ddecb | 5 | @Override
public void rodarJogo(){
if (JOptionPane.showConfirmDialog(null, "\nUsar midia física?\n","Iniciando...",JOptionPane.YES_NO_OPTION) == 0 ){
this.jogoRodando = JOptionPane.showInputDialog(null,"\nInforme qual o jogo a executar\n","Iniciando...",JOptionPane.INFORMATION_MESSAGE);... |
71844b64-74ab-45dc-afd6-9f6631647903 | 7 | protected void beAttrib(final char c)
{
switch(c)
{
case ' ': case '\t': case '\r': case '\n': bufDex++; return;
case '<':
piece.innerStart = bufDex;
abandonTagState(State.BEFORETAG);
return;
case '>':
changeTagState(State.START);
piece.innerStart = bufDex;
return;
case '/':
endEmptyAt... |
c01dac4c-2ced-4825-8802-ad577f100e33 | 0 | public void paintIcon(Component c, Graphics g, int x, int y) {
Graphics2D g2 = (Graphics2D) g.create();
g2.translate(x, y);
// Draws the state.
paintConfiguration(c, g2, getIconWidth(), getIconHeight());
g2.translate(-x, -y);
} |
677b8a7c-6c0c-48f3-b8df-a3cac101e9d1 | 9 | public static void writeWaveformToFile(AudioPoint in, File out){
AudioPoint temp=in;
while(temp.getNext()!=null)temp=temp.getNext();
double xscale=1.2;
double yscale=0.05;
int xstart=in.getX();
int imgw = 3200;
imgw = (int)((temp.getX()-xstart) * xscale);
System.out.print("\nExporting...");
System.out... |
807e9d7a-3a06-41bc-a62e-8df3aa104714 | 2 | public void quoteChar(int ch) {
if (ch >= 0 && ch < ctype.length)
ctype[ch] = CT_QUOTE;
} |
3778b5f7-5839-413a-aa8b-41038829d084 | 9 | public void executeBatch(){
LOGGER.info("executing batch");
try {
LOGGER.info("executing details");
details_ps.executeBatch();
}catch(SQLException se) {printSQLError(se);}
try {
LOGGER.info("executing publication");
publication_ps.executeBatch();
}catch(SQLException se) {printSQLError(se);}
try ... |
f4cc504d-ef69-457e-b3bd-7b9b270d6783 | 7 | public static void testValidity(Object o) throws JSONException {
if (o != null) {
if (o instanceof Double) {
if (((Double) o).isInfinite() || ((Double) o).isNaN()) {
throw new JSONException(
"JSON does not allow non-finite numbers.");
... |
6570a235-3951-40c2-81a5-4be3362da885 | 1 | private void showMatchingUpgrades(UpgradeType type){
this.upgradePanel.removeAll();
ArrayList<Upgrade> upgrades = this.game.getUpgradeManager().getUpgradesByType(type);
for(Upgrade u : upgrades){
UpgradeIconPanel uip = new UpgradeIconPanel(u);
uip.addMouseListener(this);
upgradePanel.add(uip);
}
... |
1b7b185a-02ec-41b7-b272-23e32be69d67 | 5 | public boolean checkValidMenu(int menuIndex) {
if(isLoggedIn)
if(menuIndex > 0 && menuIndex <= 7)
return true;
if(menuIndex > 0 && menuIndex <= 5)
return true;
return false;
} |
4c2de0c7-efcd-4fca-aa1d-34ac23665339 | 3 | private ArrayList<Corner> landCorners() {
final ArrayList<Corner> list = new ArrayList();
for (Corner c : corners) {
if (!c.ocean && !c.coast) {
list.add(c);
}
}
return list;
} |
c1036589-6ecc-4ef0-a4ad-29b51a7fd0c2 | 8 | public static void main(String[] a) throws IOException {
Scanner s = new Scanner(new File(a[0]));
while (s.hasNext()) {
String l = s.nextLine();
String[] x = l.split("\\ ");
int[] y = new int[x.length];
for (int i = 0; i < x.length; i++) {
y[i] = Integer.parseInt(x[i]);
}
boolean f = f... |
f1d9525e-1c23-42a3-aa0f-9402626dc669 | 9 | private int doLogin () throws InterruptedException{
boolean isLogin = false;
boolean first = true;
int count =0;
do {
if (!first){
log.error("login error. retry!");
ThreadUtil.sleep( RandomUtil.getRandomInt(YueCheHel... |
60cbe170-9283-4a93-a6aa-87a069338539 | 0 | public int getPosition() {
return carPhysics.getPosition();
} |
e85936d8-84b0-452f-a8b2-bbbfb1c8fb4c | 7 | public Phrase[] recombine(Phrase[] population, double[] fitness,
double initialLength, int initialSize,
int beatsPerBar) {
Phrase[] returnPop = population.length - ELITISM_CONSTANT >= 0
? new Phrase[population.length - ELITISM_CONSTANT]... |
aabc9b68-ba2f-4cbd-8354-3c6c72060563 | 1 | @BeforeClass
public static void setUpBe() throws Exception {
for (int i = 0; i<100 ;i++){
dequeInteger.add(i); //190 символов
dequeDouble.add(1.); //300 символов
dequeString.add("Hi!"); //300 символов
}
} |
75d92e24-8e51-4d58-9b83-d1e7c3bec46f | 2 | public boolean test(Object obj) {
int[] tab = (int[]) obj;
for (int i = 1; i < tab.length; i++) {
if (tab[i - 1] > tab[i])
return false;
}
return true;
} |
651e89a1-a150-4164-b7d8-08d64385c07a | 8 | private Component cycle(Component currentComponent, int delta) {
int index = -1;
loop : for (int i = 0; i < m_Components.length; i++) {
Component component = m_Components[i];
for (Component c = currentComponent; c != null; c = c.getParent()) {
if (component == c) {
index = i;
break loop;
}
... |
979b865e-6b4c-4242-8eec-28ebe0aa4d21 | 8 | private void doProperty(Class type, PropertyDescriptor pd, Object oldInstance, Object newInstance, Encoder out) throws Exception {
Method getter = pd.getReadMethod();
Method setter = pd.getWriteMethod();
if (getter != null && setter != null) {
Expression oldGetExp = new Expression(o... |
00fc8f4a-bc61-402f-87c1-8766ce4e9000 | 4 | public JSONObject toJSONObject(JSONArray names) throws JSONException {
if (names == null || names.length() == 0 || this.length() == 0) {
return null;
}
JSONObject jo = new JSONObject();
for (int i = 0; i < names.length(); i += 1) {
jo.put(names.getString(i), this.... |
463c700f-58ab-4575-a627-85a39921eb44 | 8 | public static void main(String[] args) throws IOException {
criba();
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String s;
StringBuilder sb = new StringBuilder();
while ((s = br.readLine()) != null) {
if (sb.length() != 0) {
... |
0b83f81a-d8ca-4353-ada0-5676967e2026 | 9 | static final public void Line() throws ParseException {
Token t;
switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
case UDP_BUFFER_SIZE:
jj_consume_token(UDP_BUFFER_SIZE);
jj_consume_token(WHITESPACE);
t = jj_consume_token(VALUE);
setUdpBufferSiz... |
c7ce7fcc-4888-4a0b-bc3f-093c5cd2f34b | 6 | private void leave(String exitString) {
/* look for a matching context */
int i;
if (exitString.equals("")) {
i = 0;
} else {
for (i = contexts.size() - 1; i >= 0; --i) {
String context = contexts.get(i);
if (context.equals(exitString))
break;
}
if (i < 0) {
System.err.println("Warn... |
8b497b9e-30db-454c-a628-b721b3ad357e | 2 | Image imageIdToImage(int id){
switch(id + faction){
case 1:
return new ImageIcon("C:\\test\\bluetestsprite.png").getImage();
case 2:
return new ImageIcon("C:\\test\\redtestsprite.png").getImage();
default:
System.out.println("returned null from imageIdToImage!");
return null;
}
} |
76577226-a3bc-43a1-a3a4-49795cb1b0dc | 5 | public boolean checkForWinAndDrow() {
if (checkForWinHorizontally() || checkForWinUpright()
|| checkForWinDiagonallyLeft() || checkForWinDiagonallyRight()) {
System.out.println(winner + " Winner!!!");
return true;
} else {
if (checkForDrow()) {
System.out.println("Drow !!!");
return true;
} ... |
c44d4e87-81e3-487c-afba-63116da9fb4c | 2 | public static boolean isHellhound (Entity entity) {
if (entity instanceof Wolf) {
Wolf hound = (Wolf) entity;
if (hound.getEquipment().getChestplate().equals(new ItemStack(Material.LEATHER_CHESTPLATE, 1, (short) - 98789))) {
return true;
}
}
re... |
12cab47f-f127-44e5-89c5-8c1c004e61e4 | 7 | @Override
public Atom parseAtom() throws IOException {
Atom atom = null;
switch (curToken.type) {
case NUMBER:
if (curToken.c.contains(".")) {
atom = new NumberAtom(Double.parseDouble(curToken.c));
} else {
atom = n... |
2d92f15b-7f3a-4bce-a66a-fe3d926782fe | 6 | public static void main(String args[]) {
/*
* Set the Nimbus look and feel
*/
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/*
* If Nimbus (introduced in Java SE 6) is not available, stay with the
* default lo... |
447ed2af-5014-4d3a-a782-c9873f11571c | 8 | @Override
public String runMacro(HTTPRequest httpReq, String parm, HTTPResponse httpResp)
{
final java.util.Map<String,String> parms=parseParms(parm);
final String last=httpReq.getUrlParameter("POLL");
if(parms.containsKey("RESET"))
{
if(last!=null)
httpReq.removeUrlParameter("POLL");
return "";
}... |
fda5326a-15e8-4fcb-b7c6-33e9c062a4d0 | 7 | public synchronized int hashCode() {
if (__hashCodeCalc) {
return 0;
}
__hashCodeCalc = true;
int _hashCode = 1;
if (getScheduledtasks() != null) {
for (int i=0;
i<java.lang.reflect.Array.getLength(getScheduledtasks());
i+... |
b35625bc-a475-41de-963c-450bbbdd01cf | 7 | public void readFile() throws FileNotFoundException,IOException
{
/* lekha - generating bigrams from big.txt instead of wikipedia corpus
BufferedReader br2 = new BufferedReader(new FileReader("big.txt"));
System.out.println("Reading corpus...");
String line2;
while((line2 = br2.readLine()) != null)
{
St... |
8b561e3c-c913-4ea9-99df-5759f1f2815e | 3 | public final JSONWriter array() throws JSONException {
if (this.mode == 'i' || this.mode == 'o' || this.mode == 'a') {
this.push(null);
this.append("[");
this.comma = false;
return this;
}
throw new JSONException("Misplaced array.");
} |
a3d41d22-b8f6-4bc3-8172-dc10acc2552f | 2 | private void clearAll() {
contEntGlo.clear();
contEntLoc.clear();
contEntTmp.clear();
contEntCons.clear();
contFlotGlo.clear();
contFlotLoc.clear();
contFlotTmp.clear();
contFlotCons.clear();
contStrGlo.clear();
contStrLoc.clear();
contStrTmp.clear();
contStrCons.clear();
contBoolGlo.clear();
... |
1deb39bc-18e9-4699-ae69-aeb792494c70 | 9 | private static void addKeyListener(JFrame frame) {
frame.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent event) {
int c = event.getKeyCode();
if (c == KeyEvent.VK_LEFT | c == KeyEvent.VK_A) {
grid.moveSelectedLeft();
} else if (c == KeyEvent.VK_RIGHT | c == KeyEvent.VK_D) {
... |
65b61549-ebeb-4151-9317-87b22c8e5fa0 | 0 | @Before
public void setUp() {
} |
bbc5c3d5-a1f0-4813-bc56-f84498c0e1cf | 7 | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
PrivateCategory that = (PrivateCategory) o;
if (colorCode != that.colorCode) return false;
if (id != that.id) return false;
if (headLin... |
50b9fd6a-90fe-443c-997d-e11cdfb99cb3 | 7 | public RabinHashFunction64() {
table32 = new long[256];
table40 = new long[256];
table48 = new long[256];
table54 = new long[256];
table62 = new long[256];
table70 = new long[256];
table78 = new long[256];
table84 = new long[256];
buffer = new byte[READ_BUFFER_SIZE];
long[] mods = new long[P_DEGREE]... |
0310d6f5-76ac-4215-ab0a-601947953dda | 8 | public static void updateRow(JTable source, int row) throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException {
AudioFile f = null;
double size = 0;
if (source == LibraryPanel.table) {
f = AudioFileIO.read((list.get(row)));
size = (double)list.get(row).length(... |
ee3ebde6-3d88-4375-8314-bfd6e409c344 | 1 | public final void visitLookupSwitchInsn(
final Label dflt,
final int[] keys,
final Label[] labels)
{
AttributesImpl att = new AttributesImpl();
att.addAttribute("", "dflt", "dflt", "", getLabel(dflt));
String o = AbstractVisitor.OPCODES[Opcodes.LOOKUPSWITCH];
... |
d8f3dc57-4071-4bc4-9eed-c17efd2d5ed4 | 8 | @SuppressWarnings("unchecked")
public int addPhoto(String filename, String caption, String albumName, File pic) {
Photo p = new Photo(filename, GuiView.control.getCurrentUser().getID(), caption, albumName, pic);
if (GuiView.control.getCurrentUser().getAlbumList().containsKey(albumName)) {
Iterator it = GuiV... |
950fc052-6cb8-4711-9d75-dc68b2959b37 | 9 | ErosionDilatation(final boolean current_selection[], int kernel_size,
int width, int height, boolean dilate) {
// two different selection outputs will be generated, see below at
// methods: one "final" and one with just the changed pixels
this.new_selection = new boolean[current_selection.length];
for (int ... |
33807865-8dce-4e41-80dc-7c2f2e54fa62 | 5 | public void pack () {
checkWidget ();
CTableItem[] items = parent.items;
int index = getIndex ();
int newWidth = getPreferredWidth ();
for (int i = 0; i < parent.itemsCount; i++) {
int width = items [i].getPreferredWidth (index);
/* ensure that receiver and parent were not disposed in a callback */
if (paren... |
b93e1435-4e00-4cb8-a9c2-b5ce9bd2e3c6 | 5 | private Set transitionFunction(String word, Set currentStates) {
Set tmpSet = new Set(currentStates);
if (word.length() == 1) {
for (State state : currentStates) {
tmpSet.addAll(state.transition(word));
tmpSet.remove(state);
}
Iterator<State> it = tmpSet.iterator();
while (it.hasNext())
tmpS... |
deb6e7b4-f071-481c-be36-efd8dc32489d | 5 | private void drawNode(RBNode node, int curLevel, int leftPos, int rightPos) {
if (node == null) return;
// try{Thread.sleep(100);} catch(Exception e) {}
if (node.getColor() == com.andreydev.rbtree.Color.BLACK) {
window.setColor(black);
} else {
window.setColor(red... |
c382d66a-7bc2-4601-9ef0-94d6c82d0198 | 3 | public static String[] split(String toSplit, String delimiter) {
if (!hasLength(toSplit) || !hasLength(delimiter)) {
return null;
}
int offset = toSplit.indexOf(delimiter);
if (offset < 0) {
return null;
}
String beforeDelimiter = toSplit.substring(0, offset);
String afterDelimiter = toSplit.substri... |
7f957910-a18b-4525-9780-a5391c5dba4b | 9 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
final MOB target=this.getTarget(mob,commands,givenTarget);
if(target==null)
return false;
if(!super.invoke(mob,commands,givenTarget,auto,asLevel))
return false;
final boolean success=prof... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.