method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
4f6c714a-cf79-4992-b2a2-92e94bf94ce5 | 9 | public final static Deserializer init(final SongData sdc, final MasterThread master) {
final Path idx = getIdx(sdc.getRoot());
final IOHandler io = sdc.getIOHandler();
final Map<String, AbstractInputStream> zipEntriesMap;
if (!idx.exists())
zipEntriesMap = null;
else
zipEntriesMap = io.openInZip(idx);
... |
66b1a01a-85d2-4f29-8ca3-c6fd98ceee62 | 7 | public void exportClass() {
//Check if there is any diagram objects to export
if (vod.size() == 0) {
//If not, display error message box
JOptionPane.showMessageDialog(null, "No information available to export", "UMLator | Export Error", JOptionPane.ERROR_MESSAGE);
} else { //Otherwise..
//Display sav... |
d54104e8-35af-47be-8ff0-50c2a5975aba | 3 | public static Map<Integer, ZState> createStates(List<Connection> connections){
Map<Integer, ZState> states = new HashMap<>();
for(Connection connection: connections){
if(!states.containsKey(connection.from)){
states.put(connection.from, new ZState(connection.from, co... |
7e9d90db-f805-4563-b480-29f6639b6150 | 2 | private void makeToggleButtons() {
displaySpeedButton.setGraphic(
new ImageView(ImageGetter.getTeXImage("Instant \\leftarrow Step")));
modeButton.setGraphic(
new ImageView(ImageGetter.getTeXImage("Compact \\leftarrow Full")));
displayResponseSpeedButton.setGraphic(
new ImageView(ImageGetter.getTeXIma... |
bc502568-bbb9-41df-af8a-09e093f3d6a5 | 8 | public boolean isCollision()
{
for(int i=0;i<4;i++)
{
if(sqrBlock[i].getX()<=-1||sqrBlock[i].getX()>=10)//出界
return true;
else //触及其他积累的块
{
for (int k = 0; k < 10; k++) {
for (int j = 0; j < 20; j++) {
... |
21ba5209-31ad-4ac2-8e2b-7d3481a83762 | 3 | private void updateStateToolRight(List<Keyword> keywords, List<String> terms, List<String> approval) {
RecipeLearningState nextState;
if (approval.isEmpty()) {
DialogManager.giveDialogManager().setInErrorState(true);
}
else if (approval.get(0).equals("yes")) {
nextState = new RecipeLearningState();
nextState.... |
d6917e8c-f455-4654-bbcf-406e603ac225 | 7 | public static void main(String... args) throws IOException {
MyScanner sc = new MyScanner();
int n = sc.nextInt();
long[] dg1 = new long[2*n];
long[] dg2 = new long[2*n];
int[][] a = new int[n][n];
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; ... |
0a0f97ac-05b7-4548-8435-04b9083cd664 | 6 | public static ArrayList <ToolData> loadData() {
File load = new File("resources/files/ToolData/");
Gson loader = new Gson();
ArrayList <ToolData> res = new ArrayList <ToolData>();
for (File f : load.listFiles()) {
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(f));
} catch (FileNotF... |
6282d2d8-bbc2-4cb8-a83a-8684898f3b4c | 5 | private void generateTree(Node root) {
while (itemsCount > 0) {
int childCount = Math.abs(new Random().nextInt()) % 3;
itemsCount--;
switch (childCount) {
case 0: {
root.right = null;
root.left = null;
... |
9fd5920b-90a5-4cca-b98e-f0fa6169512d | 4 | public boolean findWord (String word) {
if (word == null || word.length() == 0) {
return false;
}
TrieTree curNode = this;
int pos;
char c;
for (int i = 0; i < word.length(); i++) {
c = word.charAt(i);
pos = c - 'a';
if (curNode.child[pos] == null) {
return false;
} else {
curNode = c... |
fdfc5f0b-d7c8-4ae1-8207-a65dd7bfd25d | 7 | public boolean add(Behaviour plan) {
if (plan == null) return false ;
final boolean finished = plan.finished() ;
final float priority = plan.priorityFor(actor) ;
final Behaviour nextStep = plan.nextStepFor(actor) ;
if (finished || priority <= 0 || nextStep == null) {
if (verboseReject && ... |
70779607-e029-42ab-9ae0-b4e1187db0d6 | 2 | @Override
public int compare(GraphNode x, GraphNode y)
{
if (x.cost < y.cost) {
return -1;
} else if (x.cost > y.cost) {
return 1;
} else {
return 0;
}
} |
948e8fbc-1294-4a9d-b7ae-5a3c59689982 | 7 | static double[][] floydWarshall2(double[][] mAdy){
int N; double[][] res = new double[N=mAdy.length][N];
for(int i=0;i<N;i++)for(int j=0;j<N;j++)res[i][j]=mAdy[i][j];
for(int k=0;k<N;k++)
for(int i=0;i<N;i++)
for(int j=0;j<N;j++)
if(res[i][k]<Double.MAX_VALUE&&res[k][j]<Double.MAX_VALUE)
res[i][j]=Math.mi... |
4579814b-64e6-44de-9508-0a8a9f60dc93 | 7 | @Override
public void run() {
// adjust to perfectFailure or EventuallyPerfectFailure
int timeout = Delta + perfectFailure();
while (true) {
try {
Thread.sleep(1000);
}
catch (InterruptedException e) {
e.printStackTrace();
}
// **Test
printSuspected();
// go through... |
648b912c-59e4-4a35-a316-a94ac028bcff | 7 | private WSResponse addCalData(WSResponse response, CalendarData calData) {
if(calData!=null){
if(calData.getEvents()!=null && calData.getEvents().size()>0){
for (CalEvent cal : calData.getEvents()) {
Events event=new Events();
event.setMessage(cal.getMessage());
event.setSource("googlecalendar")... |
fdd6d587-240e-4d77-8ba6-6e4d6218bac5 | 7 | public void clickButtonAtJXList(org.jdesktop.swingx.JXList list,
Point pointer) {
int index = list.locationToIndex(pointer);
if (index >= 0) {
JPanel o = (JPanel) list.getModel().getElementAt(index);
pointer.y -= (o.getHeight() * index);
if (o.contains(pointer)) {
Object oO = ((Component) o).getComp... |
8fd83b4b-af84-4f7f-bdb1-1de70b039175 | 5 | public Object [][] getDatos(){
Object[][] data = new String[getCantidad_Cuentas ()][colum_names.length];
//realizamos la consulta sql y llenamos los datos en "Object"
try{
if (colum_names.length>=0){
r_con.Connection();
String c... |
6b81859e-af30-430c-8b8f-921e257b3e13 | 9 | protected boolean wantBraces() {
StructuredBlock block = subBlock;
if (block == null)
return false;
for (;;) {
if (block.declare != null && !block.declare.isEmpty()) {
/* A declaration; we need braces. */
return true;
}
if (!(block instanceof SequentialBlock)) {
/*
* This was the las... |
a3dddd53-766b-40bf-8e88-be65c6016c1c | 7 | private void movingToResPile(GameSpot fromSpot, GameSpot toSpot,
int numberOfCardsToMove) {
Deck fromDeck = getDeck(fromSpot);
Card fromCard = fromDeck.showTopCard();
switch(getDeck(fromSpot).getTopCard().getSuit()){
case HEART: toSpot = GameSpot.RESOLUTION_HEARTS;
break;
case DIAMOND: toSpot = GameSpot... |
854e6339-8437-4f44-a480-24e919b039cc | 4 | public Set<Coordinate> getLegalMoves(Coordinate startingCoord, Board board) {
Set<Coordinate> legalMoves = new LinkedHashSet<Coordinate>();
Color color = board.getPiece(startingCoord).getColor();
int[] deltaX = {1, 2, 2, 1, -1, -2, -2, -1};
int[] deltaY = {2, 1, -1, -2, -2, -1, 1, 2};
for (int i = 0; i < d... |
217864d2-0cfe-4a88-834a-32ca0b5bb525 | 2 | public String getScore(){
rover = head;
String blank = "";
while(rover!=null){
if(rover.status == 1){
blank = blank + rover.name + " - " + rover.score + "\n";
}
rover = rover.next;
}
return blank;
} |
1ff2a4be-9bcf-4bca-8467-54ffb21a29ca | 1 | public int maxPoints(){
//Create a dummy rack and use scorePoints to get max score
Rack dummy = new Rack(rack_size, this);
int[] best = new int[rack_size];
for (int i=0; i<rack_size; i++)
best[i] = i+1;
dummy.deal(best);
return dummy.scorePoints(bonus_mode);
} |
39dab7dc-4736-456e-969c-981366ee065c | 3 | private void doUpdateFS(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String fsId = StringUtil.toString(request.getParameter("fsId"));
if(!StringUtil.isEmpty(fsId)) {
ObjectMapper mapper = new ObjectMapper();
Map result = new Ha... |
0571c6b5-b4da-4ffb-9e5c-7245917d7a30 | 4 | public void ellipse(double x, double y, double semiMajorAxis, double semiMinorAxis) {
if (semiMajorAxis < 0) throw new RuntimeException("ellipse semimajor axis can't be negative");
if (semiMinorAxis < 0) throw new RuntimeException("ellipse semiminor axis can't be negative");
double xs = scaleX(x... |
d36a0524-9735-4a08-8c7c-2e88241a7dc0 | 6 | public final int reverseScan(int from, byte[] sign, int limit) {
pos = from - sign.length;
if (pos < 0) {
pos = 0;
return -1;
}
int scanto = pos - limit;
if (scanto < 0) scanto = 0;
boolean found;
while (pos >= scanto) {
fou... |
3049c82d-4d59-4edc-a892-7577988d32f9 | 9 | public void noteStk(int s,int a) {
if (Debug.enabled)
Debug.check(cW<=mW);
if ((s>=0) && (s!=9)) {
cW--;
if ((s & (~2)) == 5) cW--; // Note additional word for J and D
if (Debug.enabled)
Debug.check(cW>=0);
};
if ((a>=0) && (a!=9)) {
cW++;
if ((a & (~... |
69905dcd-dca7-479a-a67f-0c47e3e60a25 | 4 | public Boolean setGridArray(int x, int y, Game.PlayerTurn pt) {
boolean test = false;
if (test || m_test) {
System.out.println("FileManager :: setGridArray() BEGIN");
}
m_gridArray[x][y] = pt;
if (test || m_test) {
System.out.println("FileManager :: setGridArray() END");
}
... |
1524e244-a033-4c0d-beef-ee3df8b3e6ba | 9 | public double logScore(int nType, int nCardinality) {
double fScore = 0.0;
switch (nType) {
case (Scoreable.BAYES): {
for (int iSymbol = 0; iSymbol < m_nSymbols; iSymbol++) {
fScore += Statistics.lnGamma(m_Counts[iSymbol]);
}
fScore -= Statistics.lnGamma(m_SumOfCounts);
... |
449d975b-aeb9-4db9-b37c-9c22987c8401 | 4 | public void displayMatrix() {
System.out.println("Displaying matrix which has "
+ this.getMatrixSize() + " elements...");
for (int i = 0; i < size; i++) {
System.out.print(" +");
for (int k = 0; k < size; k++) {
System.out.print("-----+");
}
System.out.println();
System.out.print... |
157bf02a-6a3d-4261-b210-54aae2d0b7cd | 9 | public static void main(String[] args) {
SynchronizationTest1 test = new SynchronizationTest1();
long t1, t2, delta_t;
long sumTestX = 0, sumTestY = 0, sumTestZ = 0, sumTestV = 0;
// provest zadany pocet testu
for (int i = 0; i < 10; i++) {
// provest test a zmerit c... |
aecb4ef8-c9a4-49ed-98e8-ee30d91e1183 | 6 | public double loadImage(String file) {
global = GlobalMode.EditMode;
//setEdit();
lb.drawMode();
image = null;
this.scale = 1;
try {
image = ImageIO.read(new File(file));
} catch (IOException e) {
System.out.println("Error Opening File: " +... |
12e38e17-d0ca-496d-9b99-e517c00d4aaf | 9 | static final public TreeLocation Location() throws ParseException {
/*@bgen(jjtree) Location */
SimpleNode jjtn000 = new SimpleNode(JJTLOCATION);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);Token rel;
TsurgeonPattern child;
try {
rel = jj_consume_token(LOCATION_RELATION);
child = Node... |
171e9af9-3d16-4dd6-a2df-bbaefde1da3e | 3 | public TileMap loadNextMap() {
TileMap map = null;
while (map == null) {
currentMap ++ ;
try {
map = loadMap(
"maps/map" + currentMap + ".txt");
}
catch (IOException ex) {
if (currentMap == 1) {
... |
5b62be8f-5d79-4b36-8ceb-61d7232ec7d3 | 2 | public static void main(String[] args) {
ArrayQueue arrayQueue = new ArrayQueue(10);
arrayQueue.add(0);
arrayQueue.add(1);
arrayQueue.add(2);
arrayQueue.add(3);
arrayQueue.add(4);
arrayQueue.add(5);
arrayQueue.add(6);
arrayQueue.add(7);
arrayQueue.add(8);
arrayQueue.add(9);
... |
d43b3c3a-50d0-4b8d-89ce-f72c5b3e9869 | 2 | public void visitJumpInsn(final int opcode, final Label lbl) {
super.visitJumpInsn(opcode, lbl);
LabelNode ln = ((JumpInsnNode) instructions.getLast()).label;
if (opcode == JSR && !subroutineHeads.containsKey(ln)) {
subroutineHeads.put(ln, new Subroutine());
}
} |
a17b2131-ceb4-4802-9132-5477af4e5346 | 6 | @Override
public void perform(CommandSender sender, String[] args) {
List<String> GymTypes = instance.getConfig().getStringList("GymTypes");
if (args.length == 3)
{
if (args[0].equalsIgnoreCase("Del"))
{
for (String i : GymTypes)
{
// Check for the gym
if (args[1].equalsIgnoreCase(i))
... |
6f6e650e-3138-4608-a325-7b5bbe8b4419 | 9 | static byte FurnaceFix(byte data, String kierunek)
{
if (kierunek.equals("right"))
{
if (data == 2) {
return 5;
}
if (data == 4) {
return 2;
}
if (data == 5) {
return 3;
}
if (data == 3) {
return 4;
}
}
els... |
91ed4520-6a37-4a87-84e5-23bcac02007a | 5 | public static void main(String[] args) {
Integer min = 10000;
Integer max = 100000;
int socketNum = 5;
int temp = 0;
long startTime = 0;
try {
System.out.println("Server running...");
ServerSocket ss = new ServerSocket(9999);
for (int i = 0; i < socketNum; i++) {
Socket sm = new Socket("localh... |
01404dff-f76d-4130-b521-c6df3217259a | 0 | public MainConfigHandler(final File working_directory, final List<Route> routes)
{
this.working_directory = working_directory;
this.routes = routes;
} |
2abb0616-1440-4324-a667-ac2f45c12da7 | 6 | @Override public boolean getControls(String control){
if(control == "Age"){ return true;}
if(control == "Fade"){return true;}
if(control == "Mat"){ return true;}
if(control == "Dir"){ return true;}
if(control == "InMode"){return true;}
if(control == "Xfact"){return true;}
return false;} |
919816f0-96e2-48f8-89a8-2d0225dce6d5 | 3 | @Override
public void ejecutar(Stack<Valor> st, MemoriaDatos md, Cp cp)
throws Exception {
if (st.isEmpty())
throw new Exception("IR_F: pila vacia");
Valor op = st.pop();
if (op instanceof Booleano) {
if (! (boolean) op.getValor())
cp.set((int) pd.getValor());
else
cp.incr();
}
else
... |
51fd19ce-8a1d-41ff-8e4f-99ca0682fc13 | 1 | public void printListRev(){
System.out.println("Name: " + this.name + ", Age: " + this.age + ", Illness: " + this.illness);
if (lastPatient != null){
lastPatient.printListRev();
}
} |
334bd59e-9839-46b3-9407-a03816beeae0 | 5 | public static void saveTopWords(List<Datum> train, String fileName, int topK) throws FileNotFoundException, IOException{
Map<Integer, Integer> wordCount = new HashMap<Integer, Integer>();
for(Datum d : train){
int index = getIndex(d.word);
if(wordCount.containsKey(index)){
wordCount.put(index, wordCount.... |
2330e62d-bf02-41ac-b41f-c10b65ff04d5 | 0 | public String getX509IssuerName() {
return x509IssuerName;
} |
a3dfd286-f479-4c1d-b386-21ae3a29fa40 | 7 | @Override
public void sync(String name) throws IOException {
ensureOpen();
File fullFile = new File(directory, name);
boolean success = false;
int retryCount = 0;
IOException exc = null;
while(!success && retryCount < 5) {
retryCount++;
RandomAccessFile file = null;
try {
... |
03d500d7-9f1a-43f2-8337-249bf312b2f0 | 4 | private List<OfflinePlayer> getPlayers(Server server) {
Player[] online = server.getOnlinePlayers();
OfflinePlayer[] offline = server.getOfflinePlayers();
List<OfflinePlayer> players = new ArrayList<OfflinePlayer>();
for (Player p : online) {
players.add(p);
}
for (OfflinePlayer p : offline) {
... |
172a1649-30ae-49e8-94de-dd119e9670d0 | 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 look and feel.
* For details see http://down... |
67c74126-7d12-4e9c-bfc0-66f37654dcdf | 1 | private void onMoveMade(Move move) {
for (GameEventListener l : this.gameEventListeners) {
l.onMoveMade(move);
}
} |
46f3b7f8-333b-4dec-b6e5-af269e5404c1 | 2 | public void refreshImage() {
removeAll();
for (int i = 0; i < 5; i++) {
if (i >= hand.size()) {
add(new JLabel(new ImageIcon(getClass().getResource(
"resources/53.png"))));
} else {
add(hand.get(i));
}
}
revalidate();
repaint();
} |
be98fe97-7229-431e-a747-e1e2e12c420a | 9 | protected void computeRect(Raster[] sources,
WritableRaster dest,
Rectangle destRect) {
int formatTag = MediaLibAccessor.findCompatibleTag(sources, dest);
MediaLibAccessor srcMA =
new MediaLibAccessor(sources[0], destRect, format... |
bc492c8b-23fd-4440-a8c3-cedcbecd9adf | 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 look and feel.
* For details see http://down... |
fcd3a6a7-81c2-44d1-a9d1-a77db45d837d | 9 | @SuppressWarnings("unchecked")
private <F> boolean queryExternal(JoinQuery query, JoinQueryResultHandler<E, F> handler, SpatialIndex<E>.Node node1, SpatialIndex<F>.Node node2) {
for (int i = 0; i < node1.numEntries; i++) {
int k = node1 == node2 ? i + 1 : 0;
for (int j = k; j < node2.numEntries; j++) {
if... |
ee6f41ef-9dd2-4d57-b347-e24770f4e5c3 | 7 | protected @Override Module retrieveModule(final String locator, final long revision) throws StorageException {
assert (locator != null): "Supplied locator is null";
assert (!"".equals(locator)): "Proof module supplied";
assert (revision >= 0): "Invalid version number supplied";
try {
final String urlEncodedL... |
dc67af9d-c4a2-4d9a-84a1-47e2f1d7dcee | 5 | public void keyPressed(KeyEvent key)
{
switch (key.getKeyCode()) {
case KeyEvent.VK_LEFT:
nextDirection = 3;
break;
case KeyEvent.VK_RIGHT:
nextDirection = 1;
break;
case Key... |
810436d0-0f49-47d9-9813-739dda854fd2 | 2 | public static byte[] getXmitBytes(ROJoystickHandler joystickHandler, boolean heartbeat) {
byte messageType;
if (heartbeat)
messageType = ROMessageTypes.HEARTBEAT_PACKET;
else
messageType = ROMessageTypes.CONTROL_PACKET;
byte[] header = { messageType };
if (!heartbeat) {
... |
f54eaa7d-94c8-4b05-824d-c9f578d8ad11 | 8 | final void method3446(ByteBuffer class348_sub49, Class197 class197) {
int i = class348_sub49.getUByte();
((Class349) this).anIntArray4299[0] = i >> 4;
((Class349) this).anIntArray4299[1] = i & 0xf;
if (i != 0) {
anIntArray4304[0] = class348_sub49.getShort();
anIntArray4304[1] = class348_sub49.getShort();
... |
de75a386-36bf-4de6-86f4-b6d8fdd5e8d1 | 5 | public Renter getRenterByID(String token, String ID) throws AccessException{
if(token != "abcd1234") throw new AccessException("Access denied");
try {
boolean notFound = true;
Iterator<Renter> I = this.renters.iterator();
while(I.hasNext()){
Renter temp = (Renter)I.next();
if(ID.equals(temp.getID()))
... |
051c3c7e-3314-4442-af1f-9b8b4302c631 | 6 | public void update() {
// update position
getNextPosition();
checkTileMapCollision();
setPosition(xtemp, ytemp);
// check flinching
if (flinching) {
long elapsed = (System.nanoTime() - flinchTimer) / 100000;
if (elapsed > 400) {
flinching = false;
}
}
// if we hit a wall, go the other way!... |
91a5f462-5e5a-4833-a678-98da00a5c9b2 | 7 | public static boolean fieldChanged(String existing, String incoming) {
if (existing != null && existing.isEmpty())
existing = null;
if (incoming != null && incoming.isEmpty())
incoming = null;
return (existing == null && incoming != null || existing != null
&& !existing.equals(incoming));
} |
efc8af51-cedb-4dfb-9260-974230367c7a | 0 | public String getYKey(){
return getAxisKey(Axis.Y);
} |
539c902a-b35e-4e64-a171-2a15bc23f713 | 6 | @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerJoin (PlayerJoinEvent event){
Player player = event.getPlayer();
World world = Bukkit.getServer().getWorld(plugin.lobbyWorld);
Location location = player.getLocation();
if (plugin.tpToSpawnOnLogin){
location = this.getNewLocation(wor... |
439ccb17-ad26-4fc9-97b0-d4f7841fcd8a | 0 | public synchronized Queue<WebPage> getUnsearchQueue() {
return unsearchQueue;
} |
3f849d0a-393e-4964-a3ef-5477dc7299cf | 5 | private void invisibility (Player player, int level, ItemStack i) {
int duration = 0;
int cooldown = 1000;
if (level == 1) {
duration = 200;
} else if (level == 2) {
duration = 300;
} else if (level == 3) {
duration = 400;
}
if (invisDurabilityTimer.cooldownMap.get(player) == null) {
... |
439453eb-58e5-4b89-9415-a60ebd81d81e | 9 | public boolean skipPast(String to) throws JSONException {
boolean b;
char c;
int i;
int j;
int offset = 0;
int length = to.length();
char[] circle = new char[length];
/*
* First fill the circle buffer with as many characters as are in the... |
9f994f52-3863-4bf6-ba80-936533343942 | 7 | private void uploadBedFile(){
File peptideFile = new File(bedFile);
//
int id = 0;
int chromosomeName = -1;
int startLocation = -1;
int stopLocation = -1;
String sequence = "";
String score = "";
int strand = -1;
String color = "";
String blockCount = "";
String blockSize = "";
String blockSta... |
fd7d6ad4-17a4-432b-ade5-4d7836da7892 | 8 | private int hasPlayers(JTileResource tile) {
int counter = 0; // Le compteur de villes ennemies.
int townNumber = 0; // Le numero de la ville etant parcourue.
int ennemieNumber = -1; // Le numero du dernier joueur ennemi rencontre (initialise a -1).
boolean different_ennemies = false; // Un booleen indiquant si... |
143ec364-71c1-46a1-9949-fd1f90d4a982 | 4 | private Collection<Enemy> createEnemies(Integer i, Byte b) {
Collection<Enemy> newEnemies = new LinkedList<Enemy>();
System.out.println("EnemyID: " + i);
switch(i){
case Definitions.EnemyOneID:
for (int x = 0; x< b; x++){
newEnemies.add(new EnemyOne());
}
break;
case Definitions.EnemyTwoID:... |
5c710d2b-1e65-4c85-9ad5-0f8ac341e024 | 1 | private static void withoutGenerics() {
Container c = new Container();
String s = new String("it is a string");
c.setInternal(s);
//...
String internal2 = (String) c.getInternal();
System.out.println(internal2);
c.setInternal(new Integer(5));
// ...
// String internal3 = (String) c.getInternal... |
4b8be54f-3eca-4474-b785-e1347b894e98 | 4 | public boolean pad(int width) throws IOException {
boolean result = true;
int gap = (int) this.nrBits % width;
if (gap < 0) {
gap += width;
}
if (gap != 0) {
int padding = width - gap;
while (padding > 0) {
if (bit()) {
... |
64789186-9501-4c29-a27d-33caf2a4fd68 | 1 | private void initPrefetch() {
if (theWorker == null) {
state = UIState.READCACHEPAGES;
lblStatus.setText("Prefetching");
theWorker = new MyWorker(rootPage, JobType.READCACHEPAGES, false);
theWorker.execute();
disableButtons();
}
} |
c29f818f-7171-49cd-9f42-cc8aeed2ac7e | 4 | public void exit(){
threadExit.start();
while (!threadExit.getState().equals(Thread.State.TERMINATED)) {
if (gui.isAborted()) {
setTransportationState(TransportationState.ABORTED);
break;
} else {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
logger.error(Th... |
f2a830a8-66a9-4ae3-8b8c-09cab785b9b7 | 3 | public int addToArray(treeNode node, int[] array, int index) {
int newIndex = index;
if (node == null)
return index;
if (node.leftLeaf != null) {
newIndex = addToArray(node.leftLeaf, array, index);
}
array[newIndex] = node.value;
newIndex++;
if (node.rightLeaf != null) {
newIndex = addToArray(n... |
b5786ccc-d879-4201-845e-5452474d57c7 | 0 | @Basic
@Column(name = "FUN_APELLIDOS")
public String getFunApellidos() {
return funApellidos;
} |
71a1b842-babd-4399-9db7-f7e3783e1c74 | 4 | @Override
public void tick() {
if(InputHandler.isDown("up")){
this.translate(0, -3);
}else if(InputHandler.isDown("down")){
this.translate(0, 3);
}
if(InputHandler.isDown("left")){
this.translate(-3, 0);
}else if(InputHandler.isDow... |
55c48671-83d4-4394-8a05-0d556c86bbe0 | 5 | public Writer write(Writer writer) throws JSONException {
try {
boolean b = false;
Enumeration keys = keys();
writer.write('{');
while (keys.hasMoreElements()) {
if (b) {
writer.write(',');
}
Ob... |
545e27ff-660c-469f-a4be-6f52a122c377 | 2 | public static boolean parseBoolean(String text)
{
if (text == null)
{
return false;
}
return text.equalsIgnoreCase("TRUE") || text.equalsIgnoreCase("Y");
} |
fb76a323-0a36-4664-ac59-335f0daf37d1 | 2 | public String[] getTableRenameStatements(String oldTableName, Class<?> oldClass, String newTableName, Class<?>newClass)
{
StringBuilder sb = new StringBuilder("ALTER TABLE ");
sb.append(oldTableName);
sb.append(" RENAME TO ");
sb.append(newTableName);
return new String[]{sb.toString()};
} |
31447a1a-5507-4f65-ab12-19831a89c8f2 | 1 | private static String getStringFromDocument(Document doc) {
try {
DOMSource domSource = new DOMSource(doc);
StringWriter writer = new StringWriter();
StreamResult result = new StreamResult(writer);
TransformerFactory tf = TransformerFactory.newInstance();
... |
7a5a3b23-1757-4fad-9788-aa9e19c82476 | 3 | void begin() {
while(true){
if(toDo.isEmpty() == true){
toDo.add(new DefaultState(as));
toDo.addAll(done);
//toDo.add(new DefaultState(as));
done.clear();
}
else{
toDo.peek().show();
Event event = toDo.poll();
//done.offer(event);
//use event to call next
Event e... |
42a464e0-4c41-4ec8-a7d5-a4ff0bcdcb14 | 2 | private void checkOnePair() {
for (int i = 0; i < 13; i++) {
if (getNumberOfValues(i) == 2) {
myEvaluation[0] = 2;
myEvaluation[1] = i;
myEvaluation[2] = i;
myEvaluation[3] = 0;// Find leftover card
}
}
} |
d1de77c9-7281-44f9-b98e-a01289f5d6bf | 7 | protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException, SQLException {
HttpSession sesionOk = request.getSession();
if (sesionOk.getAttribute("usuario") != null) {
response.setContentType("text/html;charset=UTF... |
6a9dbab6-c487-4b45-acb1-6a2c76bc3baf | 1 | @Override
public String toString() {
return comp + "%" + field.getName() + " - " + (data == null ? null : data.getValue());
} |
c2c5a7bf-325a-4e12-b498-105af0b080db | 8 | public void setName(String s) {
if (FileUtilities.isRelative(s))
s = FileUtilities.getCodeBase(page.getAddress()) + s;
hotLink = s;
miJNLP.setEnabled(FileUtilities.isRemote(hotLink));
if (linkPropertiesDialog == null)
linkPropertiesDialog = new LinkPropertiesDialog(page);
linkPropertiesDialog.setLink(s)... |
e357b75e-b1d2-494f-a2bb-9663df50ac89 | 2 | public String getCode(){
int paramPullCount = paramlist!=null ? paramlist.tLineCount() : 0;
String str = this.printLineNumber(true) +
"goto := " + String.valueOf(this.currentLineNumber + paramPullCount + compoundStatement.tLineCount()+4) +"\n";
str += this.printLineNumber(true) + "label := " + name.getN... |
019452be-6553-4e21-aba0-833e4eb52b5c | 9 | public int firstMissingPositive(int[] A) {
int len = A.length;
if(len == 1 && A[0] != 1) return 1;
int i = 0;
while (i<len){
if(A[i] != (i+1) && A[i] >= 1 && A[i] <= len && A[A[i]-1] != A[i]){
int temp = A[i];
int index = A[i]-1;
A... |
8b0154d8-b41d-4084-9a00-cffe864633d5 | 6 | @Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
if (debug) {
log("filtroAutenticacion:doFilter()");
}
doBeforeProcessing(request, response);
Throwable pro... |
c9b499bd-d5e3-46c6-9713-02cba5f422f4 | 6 | public static void main(String[] args){
Display d = new Display(1000,800,"Software Renderer - Running: " + args[0]);
Bitmap target = d.getFrameBuffer();
StarfieldRenderer sr = null;
if(args[0].equalsIgnoreCase("starfield"))
sr = new StarfieldRenderer(Integer.parseInt(args[1]), (float)Integer.parseInt(args[2]... |
5ed5f8cd-5ec7-4b4a-a5aa-2b05250b8e33 | 2 | public PropertiesManager() {
FileInputStream propFile = null;
try {
propFile = new FileInputStream(FILENAME);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
properties = new Properties(System.getProperties());
try {
properties.load(propFile);
} ca... |
7c128f25-9e3f-412d-98ef-12990ac879f8 | 2 | public static boolean checkZone() {
try {
if (!file.exists()) {
file.mkdir();
}
return true;
} catch (Exception e) {
return false;
}
} |
b51aa0a6-f41f-44f2-aa38-06dfa90bc987 | 0 | public boolean checkThreefoldRepititionRule() {
return false;
} |
b003738e-8528-4147-9ca7-7a6d4ea5a895 | 1 | public void testConstructor_ObjectStringEx1() throws Throwable {
try {
new MonthDay("T10:20:30.040");
fail();
} catch (IllegalArgumentException ex) {
// expected
}
} |
7bd7863b-a925-4c4c-9f6b-84daec71c835 | 1 | public static void testCycNumber() {
System.out.println("\n*** testCycNumber ***");
final CycNumber one = new CycNumber(1);
assertTrue(one instanceof CycDenotationalTerm);
assertTrue(one.equalsAtEL(1));
final CycNumber oneTwoThree = CycObjectFactory.makeCycNumber(123);
assertTrue(oneTwoThree ins... |
0605766c-eca2-4479-8672-1bf2ce76a0f0 | 8 | public static String sendGet(String url,HashMap<String, String> propertyMap){
InputStreamReader inr = null;
try{
System.out.println("get>>>"+url);
URL serverUrl = new URL(url);
HttpURLConnection conn = (HttpURLConnection) serverUrl.openConne... |
8d50bb4f-8810-481c-943d-4a4d16bbd42a | 2 | public final boolean isAlive() {
return wasStarted() && !myServerSocket.isClosed() && myThread.isAlive();
} |
b0e6a526-2ab0-46a8-8e83-e4c794f119b7 | 9 | public void create(Article article) throws RollbackFailureException, Exception {
if (article.getCommentList() == null) {
article.setCommentList(new ArrayList<Comment>());
}
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
... |
36fff7e2-8822-4271-babd-fe8c99e9831f | 5 | public void receive()
{
ActiveMQConnection connection = null;
try
{
BrokerService broker = BrokerFactory.createBroker(
"broker:(" + BROKER_URL + ")?" + BROKER_PROPS);
broker.start();
ActiveMQConnectionFactory cf =
new ActiveMQConnectionFactory(Subscriber.BROKER_URL);... |
ba3ae3da-c1da-4543-9f0b-d0c10f7fa9ee | 6 | public void backup() {
if(_outs != null && _outs[0] != null) {
_backupouts = _outs[0].toString();
for(int i=1; i<_outs.length; i++) {
_backupouts += "," + _outs[i];
}
}
if(_ins != null && _ins[0] != null) {
_backupins = _ins[0].toString();
for(int i=1; i<_ins.length; i++) {
_backupins +=... |
6ee2e099-0d72-4518-9198-b6acccd9d548 | 4 | public void processPath( PackageManager packageManager, String source )
throws IOException
{
this.transformer = new JavaCodeTransform( packageManager );
DirectoryScanner ds = new DirectoryScanner();
// I'm not sure why we don't use the directoryScanner in packageManager,
// ... |
f4689ea1-4363-44a7-926f-30e893685339 | 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 look and feel.
* For details see http://down... |
b4641f5b-ba3f-4840-9ad9-127c36a99f9e | 1 | public String mv(String src, String dest) {
String result = cp(src, dest);
if (result != null) {
return result;
}
return rm(src);
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.