method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
721280fc-b944-40cb-a945-a729c6b19de4 | 0 | public DefaultTreeDrawer(TreeModel tree) {
this.tree = tree;
tree.addTreeModelListener(this);
} |
100aab23-b3fb-484d-9818-b4b5f6594491 | 8 | public final Tuple<DenseIntMatrix, DenseIntMatrix> splitRandomMatrices(
float percentage) {
if (percentage < 0.0f || percentage > 1.0f) {
throw new IllegalArgumentException(
"Percentage must be between 0.0 and 1.0! Given " + percentage);
}
if (percentage == 1.0f) {
return new Tu... |
a1b5caa1-4dd4-452d-84eb-fccf2c2a7383 | 4 | private static void playLocallyAgainstRandomOpponent() {
try{
Random randomGenerator = new Random();
PlayChess whiteTeam = new PlayChess(Board.white);
while (true) {
System.out.println("MOVING FOR WHITE");
if (whiteTeam.board.gameIsOver()) {
System.out.println("Game over");
break;
}
... |
8f7ba241-ddca-4ab0-af09-86ac5cc15ff3 | 9 | public void paint(Graphics g, JComponent c) {
Rectangle clipBounds = g.getClipBounds();
if (header.getColumnModel() == null)
return;
//((GroupableTableHeader)header).setColumnMargin();
int column = 0;
Dimension size = header.getSize();
Rectangle cellRect = new Rectangle(0, 0, size.width, size.height);
... |
822beff2-3f50-4e11-84e9-19bbedee18a1 | 3 | @Override
public void mouseReleased(MouseEvent e)
{
super.mouseReleased(e);
if (e.getButton() == MouseEvent.BUTTON1)
movePolygon(draggedFromVertex);
else if (e.getButton() == MouseEvent.BUTTON2)
copyPolygon(draggedFromVertex);
else if (e.getButton() == Mou... |
ed4efb3a-fe82-44e5-8a6d-ae6eb5c14c01 | 1 | @Test
public void shouldThrowErrorWhenFileTypeIsNotGol() throws IOException {
//given
File tmpFile = folder.newFile("file.txt");
String filePathString = tmpFile.getAbsolutePath();
//when
try {
FileParser fileParser = new FileParser(filePathString);
fil... |
ae14be30-b44b-4008-9fc5-16edbe34f181 | 8 | public ChatClient(String s) throws RemoteException{
super();
userName = s;
int count = 1;
boolean set = false;
while(!set){
try {
Naming.lookup(userName);
userName = s + count;
count ++;
} catch (MalformedURLException e2) {
e2.printStackTrace();
} catch (NotBoundException e2) {
tr... |
1562f4aa-527b-4470-af27-b63da94f75cf | 1 | public GenericDAO<Worktype> getWorktypesDAO() {
if (_worktypesDAO == null) {
_worktypesDAO = new GenericDAO(Worktype.class);
}
return _worktypesDAO;
} |
35e21d06-8631-4c3c-9ef2-22ca2211a3f1 | 2 | public boolean put(K key, V value) {
if (!inited) {
init();
}
if (synchronizer.put(key, value)) {
data.put(key, value);
return true;
}
return false;
} |
15000531-0bda-473b-95e2-16371808d3ed | 9 | public static void dfs(int r1, int c1, int r2, int c2, int d) {
Queue<Point> cola = new LinkedList<Point>();
Queue<Integer> cola2 = new LinkedList<Integer>();
cola.add(new Point(r1, c1));
cola2.add(1);
boolean arr[][] = new boolean[8][8];
arr[r1][c1] = true;
res=1;
p:while (!cola.isEmpty()) {
Point ... |
12b9405c-7631-41c6-b341-c5e1d96c2405 | 1 | public static void toggleEditableInheritanceText(Node currentNode, JoeTree tree, OutlineLayoutManager layout) {
CompoundUndoablePropertyChange undoable = new CompoundUndoablePropertyChange(tree);
toggleEditableInheritanceForSingleNode(currentNode, undoable);
if (!undoable.isEmpty()) {
undoable.setName("Toggle... |
74320c75-320d-4f18-924e-21d510498631 | 4 | public void create(Usuarios usuarios) throws PreexistingEntityException, RollbackFailureException, Exception {
EntityManager em = null;
try {
utx.begin();
em = getEntityManager();
em.persist(usuarios);
utx.commit();
} catch (Exception ex) {
... |
2c8970fe-80d0-4595-93c5-edf1f9e63d67 | 2 | private String readLine(InputStream in) throws IOException {
StringBuffer buf = new StringBuffer();
int c;
while ((c = in.read()) >= 0 && c != 0x0d)
buf.append((char)c);
in.read(); /* skip 0x0a (LF) */
return buf.toString();
} |
2c5f51e3-d070-41af-ae4e-33b0cc6c5c96 | 3 | public static void setParameterValue(PreparedStatement ps, int paramIndex, Object inValue) throws SQLException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("绑定PreparedStatement参数: 参数列序号[" + paramIndex + "], 参数值[" + inValue + "],参数类型["
+ (inValue != null ? inValue.getClass().getName() : "null") + "]");
}
... |
e6071a18-2547-4e5b-9050-f925866ad7f0 | 2 | private String fileReader(BufferedReader br){
StringBuffer resultData = new StringBuffer();
try{
String data = null;
while ((data = br.readLine()) != null){
resultData.append(data);
}
}catch (IOException e){
e.printStackTrace();
}
return resul... |
524cbcc8-d03a-4005-9621-cd9b775f5684 | 6 | public void mDisplayLCS()
{
System.out.println("Length of Longest Common Sequence is "+
length[seq1.length-1][seq2.length-1]);
LinkedList<Integer> list = new LinkedList<Integer>();
int row = seq1.length-1, col = seq2.length - 1, temp = -1, index = -1;
whi... |
7b5f2e48-b9de-4388-bb94-ea107e8fb24f | 0 | public NFA(String regex) {
M = regex.length();
re = regex.toCharArray();
G = buildEpsilonTransitionDigraph();
} |
ae4a5f02-69b8-401a-bb53-dbb1ef82de00 | 3 | private void jTable10MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable10MouseClicked
System.out.println("Count:" + evt.getClickCount());
if (evt.getClickCount() == 2) {
String key = (String) jTable10.getModel().getValueAt(jTable10.getSelectedRow(), 3);
String ... |
1d5d309d-23ea-4a1b-8917-cf7fc6b43f9c | 0 | public ObjectFactory() {
} |
92a566a7-97df-458f-ad08-de37625fe69f | 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(target.charStats().getBodyPart(Race.BODY_FOOT)==0)
{
mob.tell(L("@x1 has no feet!",target.name(... |
4f7a51f8-cb90-472a-8da0-0675df7c7ca0 | 9 | public void moveInTrain(){
for(int i=0 ; i<receivingTrack.length ; i++){
if((receivingTrack[i].ifEmpty==true) && (countRemoveTrack > 0)
&& (blockList.get(0).get(0).timeAtReceivingArea <= Test1.time + Constants.HUMP_INTERVAL)
&& ((blockList.get(0).get(0).timeAtReceivingArea <= Test1.time1P) ||
(blo... |
b0d6ee7e-1d5a-43c4-bd0c-1d731ffeae23 | 5 | @Override
public Dimension getPreferredSize() {
int width = 0;
int height = 0;
if (mChildren[0] != null) {
Dimension size = mChildren[0].getPreferredSize();
width = size.width;
height = size.height;
}
if (mChildren[1] != null) {
Dimension size = mChildren[1].getPreferredSize();
if (width < siz... |
947f845d-6e3b-4ad2-a5a7-880dee278af2 | 2 | private void ping() {
synchronized(CONNECTION_LOCK) {
if(isConnected) {
try {
long latency = getLatency();
sendPacket(Packet.createPingPacket(clientId, latency));
logger.finest("Pinging server [" + latency + "ms]");
} catch (CouldNotSendPacketException e) {
//ignore all exceptions--who ... |
1ebc640d-24f7-4464-9c84-7924bee2e102 | 5 | static private int jjMoveStringLiteralDfa9_0(long old0, long active0)
{
if (((active0 &= old0)) == 0L)
return jjStartNfa_0(7, old0, 0L);
try { curChar = input_stream.readChar(); }
catch(java.io.IOException e) {
jjStopStringLiteralDfa_0(8, active0, 0L);
return 9;
}
switch(curChar)
{
... |
9f27125b-f8a8-4aac-8575-5ab36062290d | 4 | private static HttpResponse get(String url, String inputParam, HttpClient httpclient, Map<String, String> headers) {
HttpResponse response = null;
try {
httpclient.getParams().setIntParameter(HttpConnectionParams.CONNECTION_TIMEOUT, CONNECTION_TIMEOUT);// 连接超时
h... |
46a2340c-95d0-46d8-b957-36d4007d4f57 | 7 | public OsuFilesCopier(List<File> osuFiles) {
this.osuFiles = osuFiles;
for (File srcFile : this.osuFiles) {
File destFile = new File(ORIG_SUBDIR + srcFile.getName() + ".orig");
if (!destFile.exists()) {
writeOrigFile(srcFile, destFile);
}
else {
overwritePreference: switch (overwritePreferen... |
1363efe9-a2a7-4250-8c65-61460079ff8c | 3 | private void switchOptions() {
switch (switchMode) {
case (SWITCH_RENDERER): {
isIdle=true;
if (buffer.usesRenderer(IRenderer.RENDERER_OPENGL)) {
keyMapper.destroy();
buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
buffer.enableRende... |
dddcd8aa-313d-4bf2-9083-7b18aecd7a0d | 5 | private boolean check(String a, String b){
byte[] ab = a.getBytes();
byte[] bb = b.getBytes();
String comparison = "";
if(ab.length != bb.length) return false;
int i;
for(i = 0; i < ab.length; i++){
if(ab[i] == bb[i]) comparison = comparison + "1";
else comparison = comparison + "0";
}
... |
d5a9f362-507f-448f-bd50-8d6a55c65f0e | 3 | private void lecture(String file) {
Scanner sc;
try {
sc = new Scanner(new File(file));
while (sc.hasNextLine()) {
String s = sc.nextLine();
if (s.charAt(0) == '!') {
analyseElementsSetFile(s);
} else {
analyseRulesFile(s);
}
}
sc.close();
} catch (FileNotFoundException e) {... |
07552ade-f627-4786-8979-42d5498a2ca7 | 8 | public boolean displayModesMatch(DisplayMode m1, DisplayMode m2){
if(m1.getWidth() != m2.getWidth() || m1.getHeight() != m2.getHeight()){
return false;
}
if(m1.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI &&
m2.getBitDepth() != DisplayMode.BIT_DEPTH_MULTI &&
m1.getBitDepth() != m2.getBitDepth()){
retu... |
b5813262-2345-4608-bdeb-c107e2cdec07 | 1 | public Comic getComic(int index) {
Comic c = null;
try {
File file = new File("./Comics/" + Integer.toString(index) + ".comic");
ObjectInputStream ois = new ObjectInputStream(new FileInputStream(file));
c = (Comic) ois.readObject();
ois.close();
} catch(Exception ex) {}
return c;
} |
6f5f7ddc-6631-4dda-97e1-260534dfd63a | 0 | @Override
public T get(String id) {
return (T) database.get(id);
} |
b47097f3-f5cd-4156-acd1-78ace12fbc18 | 9 | public Settings getSettings(int rId)
{
Settings result = null;
String strStatement = "SELECT r.rThreshold, sl.slSearchSentenceLength, sl.slSearchJumpLength, sl.slSearchNumLinks, sl.slCompareSentenceLength, sl.slCompareJumpLength, r.rCheckWWW, r.rCheckIDs, se.seName, se.seURL , se.seURLSearchArg, se.seURLAuthArg, s... |
7eeb7892-d1d3-4eea-a1dc-1eff8ded482e | 7 | public static void main(String[] args) {
Locale ruLocale = new Locale("ru", "RU");
Locale.setDefault(ruLocale);
GregorianCalendar d = new GregorianCalendar();
// Capture the current day and month
int today = d.get(Calendar.DAY_OF_MONTH);
int month = d.get(Calendar.MONTH);
// Get the weekday of the f... |
eb9d54d1-3090-41f7-9b05-eb726d27c503 | 3 | @Override
public void deserialize(Buffer buf) {
targetId = buf.readInt();
if (targetId < 0)
throw new RuntimeException("Forbidden value on targetId = " + targetId + ", it doesn't respect the following condition : targetId < 0");
targetCellId = buf.readShort();
if (targetC... |
d43f8ef7-7205-4ecf-9275-84de0e715f95 | 7 | private Done unpackDone() throws MikrotikApiException {
Done done = new Done(null);
if (hasNextLine()) {
nextLine();
while (!line.startsWith("!")) {
if (line.startsWith(".tag=")) {
String parts[] = line.split("=", 2);
... |
18d57004-adf8-41f9-920e-be4072893e3c | 7 | @RequestMapping(value = {"/add", "/register"}, method = RequestMethod.POST)
public String postAddUserForm(@ModelAttribute @Valid AddUserForm addUserForm, BindingResult result, Model model, HttpServletRequest request) {
String uri = request.getServletPath();
String origin = "";
if("/user/add... |
53ec37a0-d4cc-446f-8b9c-780c4ccdce84 | 0 | public void initEffects() {
boxBlur = new BoxBlur();
boxBlur.setWidth(10);
boxBlur.setHeight(3);
boxBlur.setIterations(1);
glow = new DropShadow();
glow.setColor(Color.YELLOW);
glow.setOffsetX(0);
glow.setOffsetY(0);
glow.setRadius(1);
shadow = new DropShadow();
shadow.setOffsetX(4);
shadow.s... |
24b93cc7-f1ae-4b95-adb2-0756e07006ae | 1 | public Door(Transform transform, Material material, Vector3f openPos)
{
this.transform = transform;
this.material = material;
this.closePos = transform.getTranslation().mul(1);
this.openPos = openPos;
if(mesh == null)
{
Vertex[] vertices = new Vertex[]{new Vertex(new Vector3f(START, START, S... |
01e74ab6-6389-4045-ac9b-366b5e673bd6 | 5 | public ShellLink saveTo(String path) throws IOException {
linkFileSource = Paths.get(path).toAbsolutePath().normalize();
if (Files.isDirectory(linkFileSource))
throw new IOException("path is directory!");
if (!header.getLinkFlags().hasRelativePath()) {
Path target = Paths.get(resolveTarget());
Path or... |
0a3c7a08-c707-4452-acbc-752c4778e72e | 2 | public Object get(String key) throws JSONException {
if (key == null) {
throw new JSONException("Null key.");
}
Object object = this.opt(key);
if (object == null) {
throw new JSONException("JSONObject[" + quote(key) + "] not found.");
}
return obje... |
6200e0a0-a1a1-4915-b19a-538478438dbd | 1 | public Block createBlock(short id){
try {
return (Block)registeredBlocks.get(id).newInstance();
} catch (Exception ex) {
}
return null;
} |
7669a7d0-5641-4524-a614-3e4a06127647 | 9 | public static void main(String[] args) throws IOException {
System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", "www-proxy.cs.tcd.ie");
System.getProperties().put("proxyPort", "8080");
String repositoryUsername;
String repositoryPaswo... |
84da1982-ab02-4a51-93b9-fa0fa241c43b | 5 | @Override
public boolean xsend (Msg msg_, int flags_)
{
// If we've sent a request and we still haven't got the reply,
// we can't send another request.
if (receiving_reply) {
throw new IllegalStateException("Cannot send another request");
}
// First part ... |
2a048fd8-9df4-4986-b79f-efc380d50c85 | 6 | private static boolean method496(char c)
{
return c >= ' ' && c <= '\177' || c == ' ' || c == '\n' || c == '\t' || c == '\243' || c == '\u20AC';
} |
7767fd68-4433-4922-9f66-acf249767e97 | 9 | @SuppressWarnings({"unchecked"})
private static Map<String, Object> parseCommandLineOptions(
final String[] args) {
final DefaultOptionBuilder oBuilder = new DefaultOptionBuilder();
final ArgumentBuilder aBuilder = new ArgumentBuilder();
final SwitchBuilder sBuilder = new SwitchBuilder();
final ... |
1af3534a-292b-4289-977d-281149cbc8d1 | 3 | public List<Pair<C,C>> getPath(C leaf) {
MerkleTree.Node curNode = leafToNode.get(leaf);
if (curNode == null)
return null;
List<Pair<C,C>> path = new ArrayList<Pair<C,C>>(depth);
for (curNode = curNode.parent; curNode != null; curNode = curNode.parent) {
// The tree is left-leaning -- since there exist... |
fa56de7f-2788-4b26-95cd-89f1d1a75bd0 | 6 | private void uninvite(Player player, String[] args) {
if (args.length < 2) {
player.sendMessage("You need to specify a player to uninvite");
return;
}
Player recipient = BuildingPlanner.plugin.getServer().getPlayer(args[1]);
if (recipient == null) {
player.sendMessage(args[1]+" needs to be online.");... |
05543c54-74f7-455e-a856-23b433ae665f | 3 | public boolean equals(Object object){
if(!(object instanceof Vector2i)) return false;
Vector2i vec = (Vector2i) object;
if(vec.getX() == this.getX() && vec.getY() == this.getY()) return true;
return false;
} |
1feeffd3-db78-433d-ae0f-387772a5f8ca | 7 | private int getAlignedX(Container target) {
int left = 0;
boolean ltr = target.getComponentOrientation().isLeftToRight();
int width = preferredLayoutSize(target).width;
switch(align) {
case FlowLayout.LEFT:
left += ltr ? 0 : target.getSize().width - width;
break;
case FlowLayout.CENTER:
left +... |
8c8b0fa9-8cf9-4862-8cd5-5a87adfe1d3d | 9 | public StringBuffer printBody(int indent, StringBuffer output) {
output.append(" {"); //$NON-NLS-1$
if (this.memberTypes != null) {
for (int i = 0; i < this.memberTypes.length; i++) {
if (this.memberTypes[i] != null) {
output.append('\n');
this.memberTypes[i].print(indent + 1, output);
}
}
}
if (t... |
a3764dc9-7e02-4f61-a60b-14a61cb2f783 | 5 | private void parseXMLDocument(boolean silent) {
// "parser factory" for creating SAX parser
SAXParserFactory saxFactory = SAXParserFactory.newInstance();
// Now using the factory to create a SAX parser,which parses the XML
// file
try {
SAXParser saxParser = saxFactor... |
31f07589-48db-41fb-8bde-86be0005378e | 4 | public static void main(final String[] args) throws IOException {
int n = args.length - 1;
for (int i = 0; i < n - 1; ++i) {
MAPPING.load(new FileInputStream(args[i]));
}
final Set unused = new HashSet(MAPPING.keySet());
File f = new File(args[n - 1]);
File d = new File(args[n]);
optimize(f, d, new S... |
afa7bfe5-d192-4f84-a07a-b644bf00f9e1 | 0 | public static byte[] encryptByPublicKey(byte[] data, String key)
throws Exception {
// 对公钥解密
byte[] keyBytes = SecurityCoder.base64Decoder(key);
// 取得公钥
X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(keyBytes);
KeyFactory keyFactory = KeyFactory.getInstance(KEY_ALGORITHM);
Key publicKey = keyFa... |
541fe905-6928-4529-8f1f-a04637ed86fd | 7 | public Usuario selectDiretor() throws SQLException {
Connection conexao = null;
PreparedStatement comando = null;
ResultSet resultado = null;
Usuario user = null;
try {
conexao = BancoDadosUtil.getConnection();
comando = conexao.prepareStatement(SQL_SEL... |
be2d53cb-98a3-461f-87b9-45241a1b1853 | 2 | void sengager(VoieExterne voie) {
if (picture == null) {
try {
int ord = voie.getEnum().ordinal();
String path = getClass().getResource(images[ord]).toURI().getPath();
picture = ImageIO.read(new File(path));
char[] sortie = destination.getEnum().toString().toCharArray();
Graphics2D g2d = (Graph... |
cea7c0c6-3772-4c00-bb61-e9cb752e2783 | 1 | private String readValue(InputStream inputStream, int stringLength) throws IOException, InvalidFormatException {
byte[] bytes = new byte[stringLength];
int readBytes = inputStream.read(bytes);
if (readBytes < stringLength) {
throw new InvalidFormatException();
}
retur... |
32778acb-1d7f-4c50-a67b-962062be91d2 | 2 | public double[] rawItemRanges(){
if(!this.dataPreprocessed)this.preprocessData();
if(!this.variancesCalculated)this.meansAndVariances();
return this.rawItemRanges;
} |
1a07ddcb-fbbf-4c9d-a4a0-2ca7f45b055a | 9 | public void HuffmanBlockEncoder(final BufferedOutputStream outStream, final int zigzag[], final int prec,
final int DCcode, final int ACcode) {
int temp, temp2, nbits, k, r, i;
this.NumOfDCTables = 2;
this.NumOfACTables = 2;
// The DC portion
temp = temp2 = zigzag[... |
4c34a792-81cc-400d-881e-b0851e8473c5 | 6 | public Integer getPropertyInteger(String key, Integer defaultValue) {
try {
if (containsPropery(key))
return Integer.valueOf(getProperty(key));
if (iSaveDefaults && defaultValue != null)
setProperty(key, String.valueOf(defaultValue));
return de... |
ba93da5d-10f4-4a95-b65d-154e128aac43 | 2 | public void testGetFieldType() {
Partial test = createHourMinPartial();
assertSame(DateTimeFieldType.hourOfDay(), test.getFieldType(0));
assertSame(DateTimeFieldType.minuteOfHour(), test.getFieldType(1));
try {
test.getFieldType(-1);
} catch (IndexOutOfBoundsException... |
ef279355-bfcb-4528-b8be-bd9f194655d8 | 7 | public static boolean computeCell(boolean[][] world, int col, int row) {
boolean liveCell = getCell(world, col, row);
int neighbours = countNeighbours(world, col, row);
boolean nextCell = false;
if (neighbours < 2) nextCell = false;
if (liveCell && (neighbours == 2 || neighbours == 3)) nextCell = tru... |
92a79b4c-4b50-42e9-ba33-3140f8c4fe31 | 6 | public String toJSON()
{
Map<String,Object> parameters = new LinkedHashMap<String,Object>();
if (GoCoin.hasValue(getStatus()))
{
parameters.put("status",getStatus());
}
if (GoCoin.hasValue(getTotal()))
{
parameters.put("total",getTotal());
}
if (GoCoin.hasValue(getPage()))
... |
1996685e-5e97-4c51-8088-83b064218c94 | 0 | public String toString() {
e = new Engine();
return "Name = " + name + ", " +
"Year = " + year + ", " +
"Color = " + color + ", " +
"Engine = " + e;
} |
254fa6a1-647e-4f0d-b368-78cd810e600e | 9 | void populateMesh(Mesh m)
{
Boolean areNormals = null;
for(float[] normal:normals)
{
if(normal == null)
{
if(areNormals == null)
areNormals = false;
else if(areNormals == true)
throw new RuntimeException();
}
else
{
if (areNormals == null)
areNormals = true;
else if(... |
419422e1-1cbe-4db9-9001-6e4fe7e2e6c6 | 6 | protected void setSearchResult() {
// キャッシュ読み取り
try {
this.searchResult = (SearchResult) cache.get("searchResult");
if (searchResult == null)
throw new InvalidValueException(null);
} catch (InvalidValueException ive) {
if (searchResult == null) {
// データストア読み取り
startDatastore();
Entity sea... |
bac4197a-2ba2-491e-96af-f31607749de8 | 2 | public void loadAssembly(boolean bool){
InitializeFactory factory = new InitializeFactory();
int response = INPUT_CHOOSER.showOpenDialog(null);
if (response == JFileChooser.APPROVE_OPTION) {
if (bool){
factory.promptForEnvironment(mySimulation);
}
factory.... |
914c2015-4d62-4f77-9400-759a0a56e7d5 | 5 | private String[] parseLabels(String sql) {
if (isShowTables(sql)) {
return new String[]{"Tables_in_test"};
}
String upperSql = sql.toUpperCase();
String select = "SELECT";
sql = sql.substring(upperSql.indexOf(select) + select.length());
upperSql = sql.toUpperCase();
String from = "FROM";
sql = sql.su... |
d7b6ac22-ece2-4aeb-9181-74c610bca2a4 | 4 | private static Node insertIntoList(Node h, Node n){
if(n.v <= h.v){
n.next = h;
return n;
}
Node prev = h;
Node curr = h.next;
while(curr!=null){
if(n.v <= curr.v){
prev.next = n;
n.next = curr;
break;
}
prev = curr;
curr = curr.next;
}
if(curr==null){
prev.next = n;
pr... |
107e230c-ebf5-4772-9c0e-3a982c9f1fa1 | 2 | public static void spielfeldgenerieren() {
//12 Tische & 24 Stühle werden erschaffen; außerdem bekommt jeder Stuhl ein Land aus der Länderkartenliste. Die erste Karte 0. Selbige wird danach vom Stapel entfernt.
for(int n=0;n<12;n++) {
tische.add(new Tisch());
tische.get(n).setLand(laenderkarten.get(0));
... |
a8df706e-a7fa-4cce-8b62-4038e965bb9a | 4 | public boolean isAvailable(Date start, Date end) throws RemoteException {
if (!start.before(end))
throw new IllegalArgumentException("Illegal given period");
for (Reservation reservation : reservations) {
if (reservation.getEndDate().before(start)
|| reservation.getStartDate().after(end))
continue;
... |
742615c4-c289-49c1-b1e1-73828fc3b85d | 6 | public void overwriteTRNS(byte r, byte g, byte b) {
if(hasAlphaChannel()) {
throw new UnsupportedOperationException("image has an alpha channel");
}
byte[] pal = this.palette;
if(pal == null) {
transPixel = new byte[] { 0, r, 0, g, 0, b };
} else {
... |
07dc4b5e-589b-4f55-9169-f073e052d427 | 4 | protected Object[] convertArgs(Varargs args) {
Object[] a;
if (varargs == null) {
a = new Object[fixedargs.length];
for (int i = 0; i < a.length; i++)
a[i] = fixedargs[i].coerce(args.arg(i + 1));
} else {
int n = Math.max(fixedargs.length, args.narg());
a = new Object[n];
for (int i = 0; i < fi... |
52f97d74-3055-44f9-9f62-955a2f3a932d | 1 | private boolean indexWithinCurrentSize(int index) {
return index < currentSize && index >= 0;
} |
c007bfe2-18c9-4474-8617-e065505d9621 | 1 | public void push(final Value value) throws IndexOutOfBoundsException {
if (top + locals >= values.length) {
throw new IndexOutOfBoundsException("Insufficient maximum stack size.");
}
values[top++ + locals] = value;
} |
c8c80153-ba5b-4672-bfca-0122a19e841f | 1 | public void tableChanged(TableModelEvent e)
{
try {
// get the index of the inserted row
//tableModel.getRowSet().moveToCurrentRow();
int firstIndex = e.getFirstRow();
// create a new table model with the new data
tableModel = new PeopleTableModel(tableModel.getList(), t... |
2552374f-6108-48d3-85eb-4ade8724994b | 8 | @Override
public void mousePressed(MouseEvent e) {
recordRenderer(e.getComponent());
// Shorthand
Node currentNode = textArea.node;
JoeTree tree = currentNode.getTree();
OutlineLayoutManager layout = tree.getDocument().panel.layout;
// This is detection for Solaris, I think mac does this too.
i... |
5eca5d51-4d8f-4ce5-918d-6f0bfd0015e8 | 0 | public void removeSymbols(int numberToRemove) {
environmentStack.peek().popEntriesSymbolTable(numberToRemove);
} |
1ec11f2f-1d98-4f2d-a12a-71da5e0917b2 | 9 | @Override
public void mainloop() {
while (true) {
try {
selector.select();
Iterator<?> selectedKeys = this.selector.selectedKeys().iterator();
while (selectedKeys.hasNext()) {
SelectionKey key = (SelectionKey) selectedKeys.next();
selectedKeys.remove();
if (!key.isValid()) {
Sy... |
3d46b367-8caf-42a0-9dae-31decf82abf4 | 3 | private int[] processBatchResult(PreparedStatement ps, int[] rows, boolean clearKeys,
final KeyHolder generatedKeyHolder) throws SQLException {
if (generatedKeyHolder != null) {
List<Map<String, Object>> generatedKeys = generatedKeyHolder.getKeyList();
// 如果clearKeys为true,表示为第一次调用,需要清除generatedKeys中的原有值。
... |
1a437543-ba2d-49d1-b6ee-68994bdad4b4 | 2 | @Override
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) {
if (qName.equals(E_ITEM)) {
int size = getSize();
addName(size, atts.getValue(A_NAME));
addFind(size, atts.getValue(A_FIND));
addReplace(size, atts.getValue(A_REPLACE));
addIgnoreCase(size, a... |
d200df67-0159-4466-acb4-962e811db773 | 4 | public void init(){
try {
clip = AudioSystem.getClip();
clip.open(this.audio);
clip.addLineListener(new LineListener() {
@Override
public void update(LineEvent arg0) {
if(arg0.getType() == LineEvent.Type.START){
}else if(arg0.getType() == LineEvent.Type.STOP){
clip.loop(Clip.L... |
ad586260-2651-47e7-81f0-09710736d2e2 | 0 | public String getState(){
return state;
} |
2b0f556f-92c7-4ad6-b0b0-44dd0c9d1ba1 | 3 | public String getServerValue(String serverId, String nodeName) {
NodeList serversNodes = document.getElementsByTagName("servers");
NodeList serverNodes = serversNodes.item(0).getChildNodes();
String value = null;
for (int i = 0; i < serverNodes.getLength(); i++) {
Node serve... |
3fe4f326-b559-43b4-b623-0075cb3b7816 | 3 | int getPaletteIndex(int rgb)
{
ColorRecord rec;
for ( int itable = rgb % hTable.length;
(rec = hTable[itable]) != null && rec.rgb != rgb;
itable = ++itable % hTable.length
)
;
if (rec != null)
return rec.ipalette;
return -1;
} |
04b92dc3-c39d-4466-b83b-6012dbd705b8 | 7 | Space[][] getOpenSets(Space sp) {
Space[][] sets = new Space[getNumOpenSets(sp)][5];
int index = 0;
if (getNumOpenSets(sp) != 0) {
if (isOpenForPiece(board[sp.pos[0]], sp.piece)) {
sets[index] = board[sp.pos[0]];
index++;
}
if (isOpenForPiece(getColumn(sp.pos[1]), sp.piece)) {
sets[index] = g... |
3bc4bc9f-f914-4876-8f7f-198940dfe95d | 3 | public static boolean isPrinterAvailable(String printerName) {
DocFlavor myFormat = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
PrintService[] printers = PrintServiceLookup.lookupPrintServices(myFormat, aset);
for (PrintSer... |
3b9422ea-74cf-4ff3-80a6-00987289c8dc | 5 | private void calculateNode(Node n, Set<Node> doneNodes, Set<Node> openNodes) throws Exception {
try {
if (!openNodes.contains(n)) {
if (n.getType() != NodeType.INPUT) {
openNodes.add(n);
}
if (!doneNodes.contains(n)) {
... |
9624ce41-2e60-43d4-8ef3-813adc787e6e | 8 | public void sort(int order, int param){
//Ascending
if(order == ASC){
switch(param){
//Name
case 1:
Collections.sort(list);
break;
//Cost
case 2:
Collections.sort(list, Item.COMPARE_BY_COST);
break;
//Weight
case 3:
Collections.sort(list, Item.COMPAR... |
cd00a11f-ff3e-44a1-a869-ecee7cc72dfb | 7 | @Override
public void executeMsg(final Environmental myHost, final CMMsg msg)
{
super.executeMsg(myHost,msg);
if((affected instanceof Item)
&&(msg.targetMinor()==CMMsg.TYP_PUT)
&&(msg.amITarget(affected))
&&(msg.tool() instanceof Item))
process((Item)msg.tool());
else
if((affected instanceof Room)
... |
b400bacc-d2b4-4b45-a1e8-cd99c70995c9 | 7 | private String scanLineBreak() {
// Transforms:
// '\r\n' : '\n'
// '\r' : '\n'
// '\n' : '\n'
// '\x85' : '\n'
// default : ''
char ch = reader.peek();
if (ch == '\r' || ch == '\n' || ch == '\u0085') {
if (ch == '\r' && '\n' == reader.peek(1))... |
2001977b-692c-4d76-9c71-d9cd61f7cd5a | 9 | private int alpha_beta(BoardNode root,int a, int b, int d) {
int i,var;
BoardNode tmp;
if(d==0){/*if reach the max depth, return the static value */
var = this.evaluator.Evaluate(root, this.myClr);
return var;
}
if (root.isMAX){/*for max node*/
for(i=0;i<7;i++)
{
if((tmp=root.NewNode(... |
7dc72ccc-b14e-4858-b938-576d9c02444b | 5 | public int getKindOf(String name) throws JackException {
int kind;
if (parameters.containsKey(name)) {
kind = KIND_PARAMETER;
}
else if (locals.containsKey(name)) {
kind = KIND_LOCAL;
}
else if (subroutineType != SUBROUTINE_TYPE_FUNCTION && fields.... |
95be2ffc-03f2-4cfb-b7e8-ab0b51349943 | 2 | public static boolean hasArg(String option) {
if (CommandLineUtilities._command_line.hasOption(option) ||
CommandLineUtilities._properties.containsKey(option))
return true;
return false;
} |
5a0eb56e-393a-44aa-83e0-ec4522c38cee | 3 | public void addLocalVar(final LocalExpr var) {
final int blockIndex = cfg.preOrderIndex(var.block());
if (StackPRE.DEBUG) {
System.out.println("add var " + var);
}
ExprInfo exprInfo = (ExprInfo) exprInfos.get(var.def());
if (exprInfo == null) {
exprInfo = new ExprInfo((LocalExpr) var.def());
... |
df551ec3-12e1-4747-99be-127bc64cb638 | 6 | private int executeTurn(Turn turn) {
TurnAction action = turn.getAction();
CombatEntity src = turn.getSourceEntity();
CombatEntity tgt = turn.getTargetEntity();
switch(action) {
case ATTACK:
int damage = src.generateDamage(DamageTypes.PHYSICAL, rng);
tgt.applyDamage(DamageTypes.PHYSICAL, damage);
... |
aea23071-9d80-490c-8eed-57ae6d63d8a1 | 7 | void createExampleWidgets () {
/* Compute the widget style */
int style = getDefaultStyle();
if (borderButton.getSelection ()) style |= SWT.BORDER;
if (mozillaButton.getSelection ()) style |= SWT.MOZILLA;
/* Create the example widgets */
try {
browser = new Browser (browserGroup, style);
} catch ... |
3cb19728-447f-4288-b8c8-451f0e077b70 | 2 | private static boolean isBreaker( char c )
{
for ( int i = 0; i < BREAKERS.length; ++i )
{
if ( BREAKERS[i] == c )
{
return true;
}
}
return false;
} |
a4841d2f-7724-4892-91ab-b7546edd7e5e | 1 | public long getPlayerCooldown(Player p)
{
if(cooldowns.get(p.getName()) == null)
return 0;
else
return cooldowns.get(p.getName());
} |
dfdba980-0cdd-4607-93db-0beafa41ab58 | 4 | public String[] splitAndRemoveEmptyLines(String str)
{
String[] data = str.split("\n");
//count the non-empty entries
int count = 0;
for (int i=0; i < data.length; i++)
{
if (!data[i].equals(""))
count++;
}
String ret[] = new Stri... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.