method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
4436ea4e-634f-4520-882b-a770d058b78f | 5 | public List<User> readCRMUsersCSV(File csvFile) {
BufferedReader br = null;
String line = "";
List<User> users = new ArrayList<User>();
try {
br = new BufferedReader(new FileReader(csvFile));
while ((line = br.readLine()) != null) {
// use comma as separator
String[] unparsedUser = line.spli... |
ef6a5091-191b-4824-8ad5-2d4afeebddf8 | 1 | public double[] getXY(double[] result, double t) {
double tant = Math.tan(t);
double sect = tant / Math.sin(t);
double x = (h + a * sect);
double y = (k + b * tant);
if (result == null) {
result = new double[2];
}
result[0] = x;
result[1] = y;
return result;
} |
15e569c5-85fb-4638-a27f-9fd95096f10f | 5 | public static void activitythread() {
while (worker) {
java.sql.Connection conn = DbController.dbconnect();
loggedin = DbController.getactivity(conn, m_loggedas);
try {
conn.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int length = loggedi... |
a5d0c63f-4b98-4460-87d7-6091e0fe20f0 | 7 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Player other = (Player) obj;
if (ID != other.ID)
return false;
if (name == null) {
if (other.name != null)
return false;
} else if ... |
6f2a35d7-6d79-400a-a83c-e5a9572f20d8 | 8 | static final public Map<String,Object> asFlatMap(Map<? extends Object,? extends Object> nestedMap){
Map flattenPropMap = new HashMap();
List<Pair<String,Map<Object,Object>>> maps = new ArrayList<>();
maps.add(new Pair("",nestedMap));
while (maps != null) {
List<Pair<String, Map<Object, Object>>> newMaps = ... |
cf5048ed-0d48-41b0-8322-31e2d4030bc6 | 7 | public static String getTextBetweenDelims( String originalText, String beginDelim, String endDelim )
{
StringBuffer sb = new StringBuffer( originalText.length() );
// Check to see that both delimiters exist in the string
if( (originalText.indexOf( beginDelim ) < 0) || (originalText.indexOf( endDelim ) < 0) )
{... |
be7dba86-ca2b-4a8f-88c1-da08ddac2075 | 8 | private void findCodelOnEdge(CodelArea area) {
DirectionPointer directionPointer = mMachine.getDirectionPointer();
CodelChoser codelChoser = mMachine.getCodelChoser();
boolean isLeft = codelChoser.isLeft();
if (directionPointer.isRight()) {
if (isLeft) {
mEd... |
c4cbabbc-67c6-46e0-b342-eaeaf5041094 | 1 | public void removeOnetimeLocals() {
if (instr != null)
instr = instr.removeOnetimeLocals();
super.removeOnetimeLocals();
} |
75736ea1-dd9f-489b-9140-5b4cfac223e3 | 5 | public boolean containsMoreThanNeeded(String msg){
int n = 0;
if(msg.length() > 300){
return true;
}
for(char a: msg.toCharArray()){
if(a == ':'){
n ++;
}
}
if(n > 1 || n == 0){
return true;
}
return false;
} |
de2c8ab1-2021-4e48-9f30-7953420c5f3b | 5 | private void drawNode(Node n, Graphics g, int x, int y)
{
if (n == null) return;
g.setColor(n.isRed ? Color.red : Color.GRAY);
if (n.parent == null) g.setColor(Color.DARK_GRAY);
g.fillOval(x, y * 64, 32, 32);
g.setColor(Color.BLACK);
if (n.left != null) g.drawLine... |
1e021c32-b719-44dd-9709-2e3a43d0ebc2 | 4 | public void seek(long pFrame) throws AudioDeviceException {
if ( !(this.mAudio instanceof SeekableAudio) ) {
throw new UnsupportedOperationException( "seeking is not possible on the current AudioFile" );
}
if ( this.mDone || this.mStopped ) {
throw new IllegalStateException( "can't seek if stopped or alread... |
f9a3b201-9169-471f-8637-f917c40e3eec | 9 | private boolean processShotInCell(Line2D shotLine, EnvironmentCell cell) {
final int agentWidth, agentHeight, bulletsNeededToKill;
double minSquaredDistance, squaredDistance, agentMinX, agentMinY, agentMaxX, agentMaxY;
BaseAgent agent, injuredAgent;
BaseInformation information;
P... |
44c02de6-f718-4f61-a9e8-8a3eac35e9d2 | 3 | private void isValidItem (int idx) throws Exception {
if ( idx < 0 && idx >= size) {
throw new InvalidItemIdException("Check Item Id!");
}
if ( cache[idx] == null ) {
throw new SoldOutException("Sold Out!");
}
} |
d4a8d3e3-5bea-4b42-87fb-e5cd9f99290e | 7 | @Override
public boolean areAdjacent(V v, V u) {
// TODO need null check.. self loops caused .next() to error.
// Check that both vertices are in our graph.
if (v == null || u == null || !vertices.contains(v)
|| !vertices.contains(u)) {
return false;
}
Iterator<E> vEdgeIter = verticesToEdges.get(v).... |
64e90e9a-4bbe-4854-8b77-5b41c0c08b06 | 0 | @Override
public Set<String> getUsers() {
return getList(userYamlConfiguration);
} |
ebfc9338-cefd-4e43-b194-f622115da835 | 0 | @Override
public void setId(String id) {
properties.put(Strings.ID, id);
} |
cb8af93d-301b-4fca-96e2-4b4e835adc95 | 1 | public void remover(Pesquisador pesquisador) throws Exception
{
String sql = "DELETE FROM pesquisador WHERE id = ?";
try
{
PreparedStatement stmt = ConnectionFactory.getConnection().prepareStatement(sql);
stmt.setLong(1, pesquisador.getId());
stmt.executeUpdate();
}
catch (SQLException e)
{
... |
fb3866c8-740f-412a-864e-f056ee581e86 | 8 | public static String urlEncode (byte [] array) {
int size = array.length-1;
byte [] out = new byte[size*3+2];
int cout=0;
size=0;
while (size<array.length) {
if (Character.isDigit(array[size])|| Character.isAlphabetic(array[size]) || array[size] == '-' ||array[size] == '_' || array[size] == '.' || array[si... |
b70f22e9-37df-4560-b725-eef66522b271 | 2 | public Document outputXMLonHTTP(String httpRequestType, URL url,
Document docToOutput) throws ProtocolException, IOException,
JDOMException {
XMLOutputter outputter = new XMLOutputter();
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod(httpRequestType);
... |
59dce13f-0a32-4ea2-bc1c-a444c8bf9185 | 8 | public static Tile of(final String representation) {
if (" ".equals(representation)) {
return AIR;
} else if ("##".equals(representation)) {
return WALL;
} else if ("[]".equals(representation)) {
return TAVERN;
} else if ("... |
07503f26-6c54-49d6-8a84-b00b45a42f82 | 4 | @RequestMapping({ "/getDestaquehome" })
@ResponseBody
public byte[] produtoEmDestaque(Integer posicao) {
byte[] image = null;
Destaque destaque = null;
try {
destaque = destaqueDAO.findDestaque(posicao);
} catch (Exception e) {
List<Produto> produtos = produtoDao.findProdutos(null);
if (produt... |
f7852fa4-4cc0-4452-9154-0b08ec2ba67b | 6 | private void setHexaFieldFromTextField() throws NumberFormatException{
this.view.tfHexaCode.removeActionListener(this);
int b = Integer.parseInt(this.view.tfBlue.getText());
int r = Integer.parseInt(this.view.tfRed.getText());
int g = Integer.parseInt(this.view.tfGreen.getText());
if (r >= 0 && r <= 255 && g ... |
44088bc1-cfd5-4746-95af-ff511cb7a538 | 9 | @Override
public List<Record> signalEndTrack(int newDepth, long timeOfEnd) {
//(pop info)
TrackInfo childInfo = this.info;
if(childInfo == null){
throw new IllegalStateException("OutputHandler received endTrack() without matching startTrack() --" +
"are your handlers mis-configured?");
... |
739534f1-16e9-4a97-ba3a-ba7207d5b4fb | 3 | public static void main(String[] args) {
SlaveCertainBookStore bookStore = new SlaveCertainBookStore();
int listen_on_port = 8081;
SlaveBookStoreHTTPMessageHandler handler = new SlaveBookStoreHTTPMessageHandler(
bookStore);
String server_port_string = System
.getProperty(BookStoreConstants.PROPERTY_KEY_... |
9408fb28-6fca-46d9-9d29-dcf7ae9a466b | 3 | public int cdlInvertedHammerLookback( )
{
return ((( ((( (this.candleSettings[CandleSettingType.BodyShort.ordinal()].avgPeriod) ) > ( (this.candleSettings[CandleSettingType.ShadowLong.ordinal()].avgPeriod) )) ? ( (this.candleSettings[CandleSettingType.BodyShort.ordinal()].avgPeriod) ) : ( (this.candleSettings[... |
61bf63cf-7ebb-445c-b8c2-5b5fdbe05d12 | 3 | @Override
public void ejecutar(Stack<Valor> st, MemoriaDatos md, Cp cp)
throws Exception {
if (st.size() < 2)
throw new Exception("MAYOR: faltan operandos");
Valor op1 = st.pop();
Valor op2 = st.pop();
if (op1 instanceof Entero && op2 instanceof Entero) {
st.push(new Booleano(((int) op2.getValor())... |
a8bd4b09-bd2b-440f-bee2-0cfadca63a51 | 7 | public static int insertMstxRecommend(int mid) {
int result = 0;
int id = getMaxNumber("mstx_recommend");
updateMaxNumber(7);// 将该字段值加1
Connection con = DBUtil.getConnection();
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = con.prepareStatement("insert into mstx_recommend(id,mid) va... |
bdb1e287-e3a6-40f9-9199-a0b26a55d57c | 3 | public static boolean isFinished(String oldpath, String newpath, int k, float threshold)
throws IOException{
List<ArrayList<Double>> oldcenters = Assistance.getCenters(oldpath);
List<ArrayList<Double>> newcenters = Assistance.getCenters(newpath);
double distance = 0;
for (int i = 0; ... |
ffe60fcf-d70d-4738-bd53-763ce046e245 | 0 | public String toString() {
return mySymbol;
} |
d0debcbc-7d35-4ef2-8507-66ce5071fdfb | 0 | public boolean isEmpty(){
return stackList.isEmpty();
} |
62f0a4f3-ec63-41a8-bee9-edc72e9088bd | 9 | public void click(int mouseclick) {
if (mouseclick == 1) {
for(int i = 0; i < choose.length; i++) {
if (choose[i].contains(Opening.mse)) {
if(i == 0) {
try {
audioHandler.soundHandler.playSound("res/Sounds/thunk.wav");
} catch(Exception e) { }
storyMode = true;
myFrame.updat... |
97fe7970-ba6d-402a-9dfb-5631fd821f43 | 6 | protected LinkedHashMap<String,List<String>> ReRangedBorrowlist(LinkedHashMap<String,List<String>> linkedHashMap){
LinkedHashMap<String,List<String>> templinkedlist = new LinkedHashMap<String,List<String>> ();
if(linkedHashMap.containsKey("name")){
templinkedlist.put("name",linkedHashMap.get("name"));
... |
8cbf1107-46f7-4c14-98e5-7a6ecc23551f | 8 | public void selectiveSuccessors(Vector<State> pStates, int pBoxIndex) {
pStates.clear();
/* If a move is possible, then add the new state in the pStates vector */
if (tryMove(boxes.get(pBoxIndex), 'U'))
if (!reusableStates.isEmpty()) {
pStates.add(reusableStates.pop());
... |
6ff6fe9e-69cb-4178-aedc-3d1ae683a05c | 2 | private static double doDouble(String value) {
try {
double val = Double.parseDouble(value);
if (val == val)// only return value if its not NaN , NaN==NaN is
// false
return val;
else
return -0.0000001;
} catch (Exception e) {
// System.out.println(" TEXT TO NUMBER ERR "+ value +" to -1e-... |
d826f1ae-8886-4600-bc54-e6dc18700ded | 9 | public void processFiles(List<FileSource> fileSources){
for (Iterator <FileSource> iterator = fileSources.iterator(); iterator.hasNext();) {
FileSource fileSource = iterator.next();
List<FileInformation> files = fileSource.getFiles();
List<FileInformation> filesWithoutMatch = new ArrayList<FileInformation>()... |
5132791b-1ed0-4328-bf20-0bc891957d79 | 9 | public void renderSprite(int xp, int yp, Sprite sprite, boolean fixed) { // gonna render a sprite
if (fixed) {
xp -= xOffset; // fixed means fixed to the level (to some coordinates in the level), not fixed to the screen
yp -= yOffset;
}
for (int y = 0; y < sprite.getHeight(); y++) {
int ya = y + yp;
... |
406d2e2b-ea25-40a8-a00f-2306fc90e874 | 8 | public boolean operadorIgual(String lexema) {
//Estado atual. O estado q0 é o estado inicial
String estado = "q0";
char caracter = ' ';
int tam = lexema.length();
int i = 0;
while (i < tam) {
/*Recebe o próximo caracter do lexema, pois a função verifica se
... |
c1bd4f76-4524-4def-9bc7-dc623bfc0ea9 | 5 | public void startPieceMovement(Chessboard board, String filePath)
{
parser = new FileParser();
try
{
input = getClass().getResourceAsStream(filePath);
BufferedReader bReader = new BufferedReader(new InputStreamReader(input));
try
{
while(bReader.ready())
{
nextLine = bReader.readLine();... |
5b80e1a0-e5c5-4bec-9933-ea06681daf2a | 1 | public void testSetEnd_RI2() {
MutableInterval test = new MutableInterval(TEST_TIME1, TEST_TIME2);
try {
test.setEnd(new Instant(TEST_TIME1 - 1));
fail();
} catch (IllegalArgumentException ex) {}
} |
d9c8d524-8c75-4d1e-a953-bfb1bdab0db4 | 2 | public boolean canRoute(String url) {
URI uri;
try {
uri = new URI(url);
} catch (URISyntaxException e) {
return false;
}
return !TextUtils.isEmpty(uri.getScheme()) && mRoutes.containsKey(uri.getScheme());
} |
6dad9129-2947-4ee1-b2e9-2c182bc60c0c | 8 | public Value newOperation(final AbstractInsnNode insn) {
int size;
switch (insn.getOpcode()) {
case LCONST_0:
case LCONST_1:
case DCONST_0:
case DCONST_1:
size = 2;
break;
case LDC:
Object cst = (... |
e334326a-80c1-47f9-ad38-4043bd3f408f | 9 | @Override
public void unInvoke()
{
if(canBeUninvoked())
{
if(affected instanceof MOB)
{
final MOB mob=(MOB)affected;
if((buildingI!=null)&&(!aborted))
{
if(messedUp)
{
if(activity == CraftingActivity.LEARNING)
commonEmote(mob,L("<S-NAME> fail(s) to learn how to make @x1.",... |
26c90110-9d51-46ce-a5e2-1fb0d31ef63e | 8 | public void saveSettings(String pFileName) {
TableViewAdapter adapter = (TableViewAdapter) getModel();
TableViewColumn[] columns = adapter.getModel().getColumns();
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.n... |
1fcc123a-48ea-4ce2-be33-f6068b7455a7 | 8 | @Override
public boolean show() {
if (!tab.open())
return false;
WidgetChild window = Widgets.get(BOOK_WIDGET, CLICK_WINDOW);
WidgetChild wc = getChild();
WidgetChild scrollbar = Widgets.get(BOOK_WIDGET, SCROLLBAR);
if (wc == null || window == null || scrollbar == null || !wc.visible() || !window.visible(... |
924946a8-2a1d-444c-a66d-d24ded9aa737 | 9 | public boolean executerRequeteSelection(String sql) {
boolean rep = true;
int num_projet = 0;
int taille = 0;
System.out.println("\tRequête à executer : " + sql);
try {
Statement ordre = conn.createStatement();
ResultSet resultat = ordre.executeQuery(sql);
int nbCols = resultat.getMetaData().getCol... |
27ed6847-ea6f-494b-a8a6-1439d9cc5888 | 0 | public JobSchedulerBuilder withCronExpression( String cronExpression )
{
this.cronExpression = cronExpression;
return this;
} |
b627d627-93f7-41de-9d8e-c052fc9fad4e | 9 | public boolean isTwoPair() {
boolean retBoo = false;
if (_cards.size() >= 4 ) {
ArrayList<Card> temp = new ArrayList<Card>();
for (Card c: _cards)
temp.add(c);
if (!(isPair()))
return retBoo;
else {
for (int i = 0; i < temp.size()-1; i++) {
for (int x = (i+1); x < temp.size(); x++) {... |
084040e2-8b24-46dc-a0f6-f747ba8a8f52 | 9 | private int insert() {
int n = getWritableFieldsCount();
String fields = "";
String separator = "";
String values = "";
Object[] valuesObj = new Object[n];
int i =0;
for(BeanTableMapping mapping: tableFields)
{
if(... |
e959de01-2469-4fee-a1f6-4f0187b65458 | 5 | private boolean isVerticallyOccupied(HantoCell from, HantoCell to){
boolean isOccupied = true;
if (to.getY() < from.getY()){
for (int i = from.getY() - 1; i > to.getY(); i--){
if (findCell(to.getX(), i) == null){
isOccupied = false;
break;
}
}
} else {
for (int i = from.getY() + 1; i < ... |
3d448835-8f5b-4d9e-a1ef-f850515f0e11 | 2 | @Override
public List<LinkDirectionCountry> load(Criteria criteria, GenericLoadQuery loadGeneric, Connection conn) throws DaoQueryException {
int pageSize = 10;
List paramList = new ArrayList<>();
StringBuilder sb = new StringBuilder(WHERE);
String queryStr = new QueryMapper() {
... |
6e564f5f-fd90-4129-a2fe-ebb7807eaf02 | 2 | public void connect() throws InterruptedException {
sess = new Session(addr, user, cookie);
synchronized(sess) {
while(sess.state != "") {
if(sess.connfailed != 0)
throw(new RuntimeException("Connection failure for " + user + " (" + sess.connfailed + ")"));
sess.wait();
}
}
} |
25a00e15-46df-4086-a9a9-4310a536ae85 | 2 | public static void deleteFiles(File dir) throws IOException {
for (File file : dir.listFiles()) {
if (file.isDirectory()) {
deleteFiles(file);
return;
}
Files.delete(file.toPath());
}
Files.delete(dir.toPath());
} |
6d0a0ff1-784e-4fdd-9da7-de1da4c3f95f | 5 | public static Position parsePositon(String s) {
if (s != null) {
if (s.compareToIgnoreCase("N-Term") == 0) return Position.NTERM;
if (s.compareToIgnoreCase("C-Term") == 0) return Position.CTERM;
if (s.compareToIgnoreCase("Protein N-term") == 0) return Position.PNTERM;
... |
fd48e334-f1d7-4e77-8c4b-95e3e13eb437 | 5 | @Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Resolution)) {
return false;
}
Resolution other = (Resolution) object;
if ((this.id == null && other.id != null... |
5dfdd537-9040-42ff-ac76-997ee9d1a520 | 1 | public String[] getBehaviorNames() {
String[] names = new String[behaviors.size()];
for(int i = 0; i < behaviors.size(); i++) {
names[i] = behaviors.get(i).getName();
}
return names;
} |
194c1a0e-a953-420c-a6bd-2dc56b0941db | 5 | public boolean isMill() {
boolean ret = false;
if ((primary != null) && (adjacent1 != null) && (adjacent2 != null)) {
char pCh = primary.getLetter();
if ((adjacent1.getLetter() == pCh) && (adjacent2.getLetter() == pCh)) {
ret = true;
}
}
return ret;
} |
3216716f-4593-4879-b272-e228041379ff | 7 | public void copyComponent(Component c) {
if (getDocument() == null)
return;
if (getDocument().getLength() <= 0)
return;
AbstractDocument.BranchElement section = (AbstractDocument.BranchElement) getDocument().getDefaultRootElement();
AbstractDocument.BranchElement paragraph = null;
AbstractDocument.LeafE... |
82e70281-f64a-4adb-a7be-4b2c99094600 | 5 | public Boolean IsModInstalled(String mod) {
boolean foundit=false;
File file = new File(McLauncher.modPath);
String[] mods = file.list(new FilenameFilter() {
@Override
public boolean accept(File current, String name) {
File mfile = new File(current, name);
if(name.endsWith(".zip") || mfil... |
7541228b-bf7b-410e-8795-216ac49216c8 | 8 | @Override
public void run() {
HttpURLConnection con = null;
try {
//TODO make this not dependent on having a headed server!!
if(Settings.getSettings().getGeneratedID() == null || Settings.getSettings().getGeneratedID().isEmpty() ) {
Settings.getSettings().setG... |
f5ec247d-0bc1-49e3-a3b2-73194f4d025e | 9 | private void writeSubstring(Kim kim) throws JSONException {
this.substringkeep.reserve();
zero();
int from = 0;
int thru = kim.length;
int until = thru - JSONzip.minSubstringLength;
int previousFrom = none;
int previousThru = 0;
// Find a substring from the subst... |
48bebc24-0515-459d-a81b-08a3be1537e1 | 6 | @Override
public InputStream post(String url, String content, HashMap<String, String> headers, String userName, String password, String domain) throws Exception {
Registry<AuthSchemeProvider> authSchemeRegistry = RegistryBuilder.<AuthSchemeProvider>create()
.register(AuthSchemes.NTLM, new JC... |
604d9ef2-4e1f-48b5-b755-63c142dab240 | 9 | public static Molecule createMolecule(String input) {
// For now, only consider ane.
if(!input.endsWith("ane")) {
System.out.println("Only alkanes are currently supported.");
return null;
}
input = input.substring(0, input.length() - 3);
int primaryLength = 1;
for(primaryLength = 1; primaryLength <... |
3a4a4a1f-58ca-4780-8d09-5093fc27a815 | 5 | private static final boolean isGuildNameAcceptable(final String name) {
if (name.length() < 3 || name.length() > 12) {
return false;
}
for (int i = 0; i < name.length(); i++) {
if (!Character.isLowerCase(name.charAt(i)) && !Character.isUpperCase(name.charAt(i))) {
return false;
}
}
return true;
... |
47b4c0a8-3606-42b5-a21d-23f63db08faf | 2 | @Override
public void adjust() {
boolean enable = false;
Component comp = getFocusOwner();
if (comp instanceof JTextComponent) {
JTextComponent textComp = (JTextComponent) comp;
enable = textComp.getSelectionStart() != textComp.getSelectionEnd();
} else {
Copyable copyable = getTarget(Copyable.class);... |
1142c9e4-2e29-4a2e-a541-a43e55e5efdf | 0 | public List<int[]> getAnthillCells() {
return this.anthillCells;
} |
6285141d-7488-490d-ae22-da96d7009e70 | 5 | private static List<Shape> buscarRefCat(List<Shape> shapes, String ref){
List<Shape> shapeList = null;
for(Shape shape : shapes)
if (shape != null && shape.getRefCat() != null && shape.getRefCat().equals(ref)){
if (shapeList == null)
shapeList = new ArrayList<Shape>();
shapeList.add(shape);
}
... |
1e17ab3e-7c41-4d23-8c42-3c82079fdf75 | 5 | private void getNextPosition() {
// movement
if (left) {
dx -= moveSpeed;
if (dx < -maxSpeed) {
dx = -maxSpeed;
}
} else if (right) {
dx += moveSpeed;
if (dx > maxSpeed) {
dx = maxSpeed;
}
}
// falling
if (falling) {
dy += fallSpeed;
}
} |
8296abf5-b14e-48ba-87c7-48e82f16f82f | 5 | @Override
public void onDisable() {
System.out.println("Disabled!");
try {
// Save the block channels
for (Entry<SpoutBlock, Integer> entry : block_channel.entrySet())
{
// Check if block still exists
if (entry.getKey().getCustomBlock() == Transmitter_Block_on
| entry.getKey().getCustom... |
d702ac68-0428-4c7f-bf8f-bca7bcf52573 | 9 | String disambiguateName(String name) throws ParsingException {
String[] fields = name.split("[.]");
if (fields.length == 2 && (!fields[0].equals("null")))
return name;
if (fields.length > 2)
throw new ParsingException("Field " + name + " is not a valid field reference."... |
2b86fa36-8ef7-4b0d-9ae9-6db5092dc22b | 5 | private T loadEntityFromObject(Class<T> loadClass, TObject object) {
T ret = null;
try {
ret = loadClass.newInstance();
for (ObjectFields of : object.getObjectFieldsList()) {
Field f = loadClass.getDeclaredField(of.getName());
if (!f.isAccessible(... |
45ccac82-907f-4a7f-8736-67147d1d3c5f | 8 | public GameState getGameState(BufferedImage screenshot) {
// pixel colour deviation threshold for valid detection
final int avgColourThreshold = 5;
// check for main menu or episode menu or level selection
BufferedImage wnd = screenshot.getSubimage(636, 24, 192, 26);
int numBytes = 3 * wnd.getWidth() * ... |
e9fef8bc-57f8-4501-ae2c-b9def34c02aa | 1 | boolean isOdd(int num){
if(num%2!=0)
return true;
else
return false;
} |
a2ad57da-8c31-4602-9867-74e2a91131ed | 2 | public void addNext()
{
next = new JButton("Next");
next.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
if (state.getTurn() == 1)
{
state.setPlayerTwoTurn();
}
else if (state.getTurn() == 2)
{
state.setPlayerOneTurn();
}
... |
14d0a0f9-7a02-4270-9567-ca9786dd9860 | 3 | public void play(BestMoveFinder bestMoveFinder) throws Throwable {
initImages();
int[][] board = null;
int[][] oldBoard = null;
while (true) {
int[][] newBoard = null;
for (int i = 0; i < 5; i++) {
newBoard = readBoard();
if (valida... |
d518dad5-8530-4614-a5da-85f29d9731ba | 1 | public void visitFieldExpr(final FieldExpr expr) {
if (previous == expr.object()) {
previous = expr;
expr.parent.visit(this);
}
} |
321305da-3a19-4855-b255-0c513b8ab682 | 9 | public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
if (args.length == 0) {
if (player == null) {
sender.sendMessage(ChatColor.RED+"This command can o... |
7fe1fe26-a447-463e-b0fb-ab90832c428e | 1 | public void draw(java.awt.Graphics2D g) {
if (gameStates[currentState] != null) {
gameStates[currentState].draw(g);
} else {
g.setColor(java.awt.Color.BLACK);
g.fillRect(0, 0, GamePanel.WIDTH, GamePanel.HEIGHT);
}
} |
071dc8d7-893f-4a35-a2c8-9d639474c9c3 | 8 | public static long[] getPath(long startStream, long targetStream) {
if (startStream <= 0) {
throw new IllegalArgumentException("startStream must not be <= 0.");
}
if (targetStream <= 0) {
throw new IllegalArgumentException("targetStream must not be <= 0.");
}
String start = Long.toBinaryString(startSt... |
30c0c590-c78e-4ea3-aa14-e2025e679ae8 | 2 | public static boolean checkForUpdates(Logger logger) {
logger.log(Logger.Level.INFO, "Checking for updates for Universal Android Toolkit. Please wait...");
BufferedReader reader = null;
boolean returnVal = false;
try {
reader = new BufferedReader(new InputStreamReader(new URL... |
3a830d57-30aa-4828-b84c-8fdbe6bcfbd3 | 7 | public void addNode(T value){
switch(value.compareTo(data)){
case -1:{
if(left==null){
left = new BinaryTreeNode(value,null,null);
} else {
left.addNode(value);
}
break;
}
case 0:{
if(left==null){
left = new BinaryTreeNode(value,null,null);
}else if(right==null){
r... |
708265e3-78e2-4d4c-bf89-049461cc56d6 | 7 | public static final int extractInteger(String buffer, int def, boolean localized) {
buffer = normalizeNumber(buffer, localized);
if (hasDecimalSeparator(buffer, localized)) {
return (int) extractDouble(buffer, def, localized);
}
int multiplier = 1;
if (hasBillionsSuffix(buffer)) {
multiplier = 100000000... |
f010553b-1f19-4f3e-9c9e-5c0afacb271a | 4 | public newLevel(int input){
state = input;
String imageString;
switch (input) {
case 1: //ShipCoordinator;
setImage("NewLevel_ShipCoordinator.png");
break;
case 2: //CargoLifter;
setImage("NewLevel_C... |
5107755d-8dfb-4a14-bee2-43f818583482 | 9 | public void draw(Object obj, Component comp, Graphics2D g2, Rectangle rect)
{
Color color = (Color) AbstractDisplay.getProperty(obj, "color");
if (color == null && obj instanceof Color)
color = (Color) obj;
Color textColor = (Color) AbstractDisplay.getProperty(obj, "textColor");
... |
dbca85b5-3516-4905-9f90-1b5828de3fbf | 6 | public static String texinfoGetParagraphCommand(String string, int start) {
{ int commandIndex = 0;
loop000 : for (;;) {
start = start + 1;
switch (string.charAt(start)) {
case ' ':
commandIndex = commandIndex + 1;
break;
case '\n':
case '... |
d056a42f-a69f-4d49-9707-404a48293aec | 6 | public byte [] getCameraStatus ()
throws IOException
{
// this is how NOT to do it!
// no error handling, no framework for other calls.
byte temp [] = new byte [8];
byte response [] = new byte [258];
int len;
temp [0] = 0x7F; // send camera status table
temp [7] = 0x1A;
// write command, receiv... |
b57f2f12-af3a-4045-9d32-bf5ba702ec35 | 2 | public static String substituteVariables(final String originalValue, final List<Variable> variables) {
if(originalValue == null) {
return null;
}
String newValue = originalValue;
for (final Variable variable : variables) {
newValue = newValue.replace("${" + variable.getId() + "}", variable.getValue());
... |
a3d0a03d-69d4-4767-b779-99763cdce137 | 4 | public void cargarTurnosTabla(boolean fechaCompleta, JTable tabla) {
DefaultTableModel modelo = (DefaultTableModel) tabla.getModel();
int i = turnos.size();
Object fila[][] = new Object[i][5];
int j = 0;
for (Turno turn : turnos) {
fila[j][0] = turn.getRealizadoPor();... |
72278c4a-f92c-4227-bb55-75dcf1f7f4d3 | 6 | public static Level loadLevel2(Global global)
{
//Verse1
Verse verse = new Verse();
verse.setVerseId(1);
verse.setVerseBgColor(Color.gray);
verse.setVerseBlockLimit(0);
verse.setVerseString("*Get to the Portal!*");
Image bgTex = global.getImageBy... |
5e8fb2bd-6f21-471f-a8b2-94f28f48e523 | 7 | protected LoginResult charcrThemePicked(final LoginSessionImpl loginObj, final Session session)
{
session.setMob(loginObj.mob);
final int themeCode=CMProps.getIntVar(CMProps.Int.MUDTHEME);
final String themeStr=loginObj.lastInput;
if(themeStr.toUpperCase().startsWith("F") && CMath.bset(themeCode,Area.THEME_FAN... |
f1484fb0-cdc4-4842-9fa9-90b52bc400a6 | 6 | public FilesBrowser(GradingPanels gradingPanes) {
super();
this.grading = gradingPanes;
currentFiles = new ArrayList<SmartFile>();
selectedFiles = new ArrayList<SmartFile>();
addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
selectedFiles = new Arra... |
3ef64f1d-957d-445b-bf78-952ca6cf793e | 7 | public void calcuateTFIDF(BufferedReader oBufferedReader)
throws IOException {
Hashtable<String, Integer> oTermVsTF = new Hashtable<String, Integer>();
String strLine = null;
while ((strLine = oBufferedReader.readLine()) != null) {
if (strLine.trim().startsWith("<top>"))
totalDocs++;
if (strLine.star... |
622f72b8-3452-4bd7-a84a-cf46820e6936 | 2 | public QuizesTaken(final int dbId) {
/*
* Add the Pane; and then creates the
* Layout for the panel, to align on the Y_AXIS (virtically)
*/
completeQuizes = new JPanel(new FlowLayout(FlowLayout.LEFT));
BoxLayout quizListlayout = new BoxLayout(completeQuizes, BoxLayout... |
cc04ece8-3457-4c32-895e-f3e3475ef515 | 4 | private String createUser(DatabaseConnection pDatabaseConnection, String pPromoteUserName, String pPassword)
throws ExInstaller {
String lPassword = pPassword;
//Prompt user for password
if (XFUtil.isNull(pPassword) ){
lPassword = CommandLineWrapper.readPassword("Enter password for new " + pPromote... |
0495c5c3-e7ec-4ee7-a4b3-ee3420ad5a92 | 3 | public static byte FFMul(byte a, byte b) {
byte aa = a, bb = b, r = 0, t;
while (aa != 0) {
if ((aa & 1) != 0)
r = (byte) (r ^ bb);
t = (byte) (bb & 0x80);
bb = (byte) (bb << 1);
if (t != 0)
bb = (byte) (bb ^ 0x1b);
aa = (byte) ((aa & 0xff) >> 1);
}
return r;
} |
b799cac6-7cfa-4c88-bc62-fdc0d3582608 | 3 | private static void peephole(final BloatContext context) {
final Set liveMethods = new TreeSet(new MemberRefComparator());
final CallGraph cg = context.getCallGraph();
liveMethods.addAll(cg.liveMethods());
// Perform peephole optimizations. We do this separately because
// some peephole optimizations do thi... |
2d6ca494-43e7-40a9-ab0b-36e1eafa8c55 | 8 | @SuppressWarnings("unchecked")
public void run() {
System.out.println("[INFO:] TalkTalkIncommingMessagesThread started");
while(!this.connection.isClosed()) {
try {
obj = connection.sockObjIn.readObject();
if(obj == null) {
continue;
}
if(obj ins... |
f4ef791a-b3ae-471e-8aec-5cfd65f1e2c5 | 9 | static int markPage(StorageImpl db, int pageId, int type, int height)
{
int nPages = 1;
Page pg = db.getGCPage(pageId);
try {
int i, n = getnItems(pg);
if (--height != 0) {
if (type == ClassDescriptor.tpString || type == ClassDescriptor.tpArrayOfByte)... |
3ba7cfd5-122f-47bb-a6e5-b9399b1e3d67 | 2 | @Override
public synchronized void receive(AisMessage aisMessage) {
// Make new queueEntry
QueueEntry queueEntry = new QueueEntry(aisMessage, new Date());
// Try to add to queue
try {
queue.add(queueEntry);
queuedMessages++;
} catch (IllegalStateException e) {
overflowMessages++;
Date now = ne... |
7ab0fc67-7593-48df-989d-c0cdf6f351f7 | 5 | private static void cleanup() {
try {
if (g != null)
g.dispose();
if (layout != null)
layout.close();
if (analyzer != null)
analyzer.close();
if (mediator != null)
... |
a04d58c9-548a-4cfb-9aa8-e1d26b3ceb16 | 6 | public void generateNumOfDistinctUsersVsFreq() throws IOException {
numUsersVsFreqFileWriter = new BufferedWriter(new FileWriter(numUsersVsFreqFile));
HashSet<Long> users = new HashSet<Long>();
TreeMap<Integer, Integer> numberOfDistinctUserVsFrequency = new TreeMap<Integer, Integer>();
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.