method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
8f28beb4-7e40-4e69-bb80-6c5bb272e35f | 3 | private int readExponent(int next, StringBuilder str) throws IOException {
if (!isExponent(next)) {
return next;
}
str.append((char) next);
next = getChar();
if (isNumber(next)) {
str.append((char) next);
next = getChar();
}
while (isDigit(next = getChar())) {
str.append((char) next);
}
... |
51ee6de4-e1eb-4168-9e75-719321a9a374 | 6 | private void setLookAndFeel() {
//<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://download.oracle.com/javase/tutorial/uiswing/lookandfeel/... |
0f1039b0-e103-48c6-bbfc-73e38f8d20e1 | 4 | private void write(String user, String event, int glID, String resName,
String status, double clock)
{
if (trace_flag == false) {
return;
}
// Write into a results file
FileWriter fwriter = null;
try
{
fwriter = new FileW... |
c8a49312-9dc4-46c2-8f03-545d98841ba1 | 9 | private boolean isLinkedDot(int x, int y, int owner) {
ArrayList<TurnCoordinate> points = new ArrayList<TurnCoordinate>();
for(int i = x - 1; i <= x + 1; i++) {
for(int j = y - 1; j <= y + 1; j++) {
if(isOnMap(i, j)) {
if(map[i][j].owner == owner... |
cc7b4d75-daf7-4a89-8a2f-b380047341ab | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
RAM other = (RAM) obj;
if (frequency != other.frequency)
return false;
if (memorySize != other.memorySize)
return false;
if (type != ot... |
16deacea-aa1c-444c-8d1e-2525ba4223e5 | 7 | public Double evaluar(Punto punto){
if(Expresion.esOperador(expresion)){
if(Expresion.esOperadorBinario(expresion)){
if(izq!=null && der!=null){
return Expresion.calcular(expresion,izq.evaluar(punto) ,der.evaluar(punto));
}
}
if(Expresion.esOperadorUnario(expresion)){
if(izq!=null){
ret... |
3a647690-f940-4a0a-bb0d-4bc1ff25f6b8 | 0 | @Id
@Column(name = "sale_id")
public int getSaleId() {
return saleId;
} |
d2f6e58f-71ed-4483-b42d-3f71cf4b1136 | 0 | public ModUserLoggedInEvent(The5zigModUser user) {
this.user = user;
} |
adf59c62-2399-4acd-a2df-d68ba363dca2 | 7 | public void setArgs(int lf, int cf, int df) throws java.io.IOException
{
if (lf < 0 || lf > 100)
{
throw new IllegalArgumentException("Illegal Loss Fraction value");
}
if (cf < 0 || cf > 100)
{
throw new IllegalArgumentException("Illegal Corruption Fraction value");
}
if (df < 0 || df... |
31ccb5c2-e79a-4a83-8185-bc888b229489 | 8 | public void sellCoupon(String id,String cou_name){
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
int count = 0;
try{
conn = getConnection();
sql = "select max(cou_num) from coupon where cou_name=? and cou_usage=0";
pstmt=conn.prepareStatement(sql);
... |
9361b38f-fe05-4bed-90d0-1dc3709ad1f7 | 0 | public void matchesInPackage()
{
Filter inMeiyoPackage = inPackage( "org.nnsoft.commons.meiyo.classpath" );
assert inMeiyoPackage.matches( MeiyoScanner.class );
assert !inMeiyoPackage.matches( List.class );
} |
e01d7e15-3995-4137-9ac3-873f56d468e3 | 3 | private boolean comparacion(JTextField piloto1, JSpinner piloto1Num, Piloto pilot1) {
boolean bol = false;
if (piloto1.getText().equalsIgnoreCase(pilot1.getName())) {
if (Integer.parseInt(piloto1Num.getValue().toString()) == pilot1.getNumber()) {
if (pitGroupNumbe... |
fb6e02e6-1fdc-4427-8a72-491f579c72e0 | 4 | public JSONObject toJSONObject(JSONArray names) throws JSONException {
if (names == null || names.length() == 0 || length() == 0) {
return null;
}
JSONObject jo = new JSONObject();
for (int i = 0; i < names.length(); i += 1) {
jo.put(names.getString(i), this.opt(i... |
223d0faa-a17a-4b0c-87e4-9084ae8dcaea | 1 | private void addStatistika(){
/*
* pairnei ola ta aparaithta stoixia apo thn vash kai ta emfanizei ston diaxiristi
*/
String oximataNum=con.getNumOfOximata(); //pairnei ton arithmo twn oximatwn ths vashs
String odigoiNum=con.getNumOfOdigoi(); //pairnei ton arithmo twn odigwn thw vashs
oximataLabel.setTex... |
105e1474-2655-46c3-94ba-30c9f7006187 | 0 | public void setOrdine(Order ordine) {
this.ordine = ordine;
} |
9bcd2e52-1f70-4b3c-91ed-509c4010ae9a | 9 | public void Validate()
{
_isValid = true;
if (!_visible || !_enabled){
return;
}
if (_isRequired){
if (_text.isEmpty() || _text.length() == 0){
_errorMessage = "Required field can not be empty.";
_isValid = false;
}... |
6d36d9fd-87b1-4d2a-83b2-8e75ae5e96e7 | 9 | private boolean tryAssign(Environment env, Lecture lecture){
double minViolation = 1;
Session bestSession = null;
int trys = 0;
for(Session s : env.sessions.objects()){
// try to assign it.
if(lecture.examLength > s.length || lecture.students.objects().size() > s.remaingCapacity()) continue;
// Go ... |
7d605298-aa69-4b4b-9da2-723444502dce | 6 | public ArrayList<ClassifiableObject> getSubsetContainingValues(String... values) {
ArrayList<ClassifiableObject> set = new ArrayList<>();
for (ClassifiableObject oc : trainingSet) {
for (String value : values) {
int success = 0;
for (ObjectFeature of : oc.getObjectFeatures()) {
if (of.ge... |
2a3f7274-d8b4-41f5-a009-f63280397249 | 5 | public World(int nWidth, int nHeight, int nCityCount, String[] args){
// TODO: Parse arguments in the TransportSim class.
// Also, do the logging stuff there.
// In fact, it'd be neat if all console output was done there.
// Now that I think of it, I should switch from System.out.println() to something custom... |
26e5c73c-f4a0-4f3a-8c36-88f5a37980f6 | 7 | private static boolean property(int[] digits){
if (digits[3] % 2 != 0)
return false;
if ((digits[2] + digits[3] + digits[4]) % 3 != 0)
return false;
if (digits[5] % 5 != 0)
return false;
if ((digits[4] * 100 + digits[5] * 10 + digits[6]) % 7 != 0)
return false;
if ((digits[5] * 100 + digits[6] * 1... |
c1771ce5-f3b4-4007-b0be-35e8172a7b91 | 2 | public static int skipType(String methodTypeSig, int position) {
char c = methodTypeSig.charAt(position++);
while (c == '[')
c = methodTypeSig.charAt(position++);
if (c == 'L')
return methodTypeSig.indexOf(';', position) + 1;
return position;
} |
8cffe3ad-f474-4eb4-9c75-b6c56239daf8 | 7 | public static void teleportPlayer( BSPlayer p, String type, String dest, boolean perm ) {
if ( !perm ) {
p.sendMessage( Messages.PORTAL_NO_PERMISSION );
return;
}
if ( type.equalsIgnoreCase( "warp" ) ) {
Warp w = WarpsManager.getWarp( dest );
if ( ... |
5d331af2-8840-4ed0-95e1-48246cd79fe6 | 5 | public Map<String, Object> clubDetails(int cid) {
Map <String, Object> info = new HashMap <String, Object>();
String sql = "SELECT * FROM club WHERE cid=" + cid;
System.out.println("clubDaoImpl:" + executeSql(sql).toString());
Map<?, ?> map = (Map<?, ?>) (Object) querySql(sql).get(0);
if (map != null) {
in... |
e3300fa8-af2f-464b-9d32-33cef6b8f8e8 | 7 | @Override
public boolean tick(Tickable ticking, int tickID)
{
if(noTickers)
return true;
for(final Ability A : myEffects)
{
if(!A.tick(ticking, tickID))
return false;
}
for(final Behavior B : myBehaviors)
{
if(!B.tick(ticking, tickID))
return false;
}
for(final Ability ... |
52af88af-d37c-4291-8667-278081fc60da | 7 | @SuppressWarnings("RedundantIfStatement")
@Override public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
GitVcsRoot that = (GitVcsRoot) o;
if (!localPath.equals(that.localPath))
return false;
if (repositoryUrl != null ? !repositoryUrl.e... |
e47c3a1b-2682-425d-bd40-2ec587787a84 | 0 | public final V getV() { return v; } |
12a7cf01-f2a1-464e-b10a-bf7abdf662c1 | 8 | public boolean equalsID (Object val)
{
if(val == this)
return true;
if(!(val instanceof Value))
return false;
if(ID == null && ((Value)val).ID == null)
return true;
if((((Value)val).ID == null && ID != null) || (ID == null && ((Value)val).ID != null))
return false;
return ((Value)val).ID.equals(I... |
2b879133-a16e-4c5b-bce9-b12ee289c09f | 0 | public static Graph getGraph() {
return g;
} |
93e483d3-6974-46a0-a454-e5db214bed17 | 1 | @Override
public void startDocument () {
this.currentParent = tree.getRootNode();
// Clear out any existing children.
while (currentParent.numOfChildren() > 0) {
currentParent.removeChild(currentParent.getLastChild());
}
} |
9394e8c6-add9-424a-832f-6de50074f6ce | 4 | public void draw() {
if(mainMenu != null)
mainMenu.draw();
if(loadMenu != null)
loadMenu.draw();
if(optionsMenu != null)
optionsMenu.draw();
if(fieldLoad != null)
fieldLoad.draw();
} |
33e5ce4f-bcad-464b-b5b3-be47780813d3 | 3 | private HashMap<String, File> putFileAndItsName(File folder){
HashMap<String, File> resultMap = new HashMap<String, File>();
File[] fileList = folder.listFiles();
if(fileList!=null){
for(File f:fileList){
if(f.isFile()){
resultMap.put(getFileNameWithoutExtension(f),f );
}
}
}
return resultMap... |
ba66761f-2e85-46ec-bbb5-49fde2a3276b | 3 | private CategoryDataset CreateTimeDataset()
{
DefaultCategoryDataset dataset=new DefaultCategoryDataset();
for(int i=0; i<timeKeyArray.size(); i++) {
for(int j=0; j<userArray.size(); j++) {
User user = userArray.get(j);
if(user.getTimemap().containsKey(timeKeyArray.get(i))) {
dataset.addValue(use... |
f59cbe08-f852-426c-bdd9-00186961310a | 4 | private boolean isEndGameSituation(Move move) {
String currentString;
if ( currentColor == BLACK ) {
currentString = "Black";
}
else {
currentString = "White";
}
// check for checkmate
if ( board.isCheckmate () ) {
moveStorage.add (move);
addHistory ();
frame.re... |
31d4aa99-b9e8-4d91-b361-6b52e928550f | 3 | public void dumpExpression(TabbedPrintWriter writer)
throws java.io.IOException {
Type flat = type.getCanonic();
int depth = 0;
while (flat instanceof ArrayType) {
flat = ((ArrayType) flat).getElementType();
depth++;
}
writer.print("new ");
writer.printType(flat.getHint());
for (int i = 0; i < de... |
28a5ed67-7d72-4704-80c7-f1c88fb1145c | 7 | public boolean isActive()
{
boolean isDown = medium.isButtonDown( getButton() ); // is the key being pressed right now?
boolean preMask = false; // would the keybinding be active without the key mask?
boolean active = false; // is the keybinding active after the key mask?
switch ( g... |
fb05f1f0-d1e2-4cd9-aea7-2e1c7b4cde22 | 1 | public void tickDown(int currentPlayerIndex) {
if (creatorIndex == currentPlayerIndex) {
remainingDuration--;
}
} |
e497dd48-a8c7-4696-a651-3b84d5948a2b | 4 | @Override
public void actionPerformed(ActionEvent ae) {
JButton source =(JButton)ae.getSource();
if (source.getToolTipText().equals("Draw Line")) {
a.getDataModel().setMode(Anim9or.DRAW_MODE);
a.setListener(0);
} else if (source.getToolTipText().equals("Draw Curve")) {
a.getDataModel().setMode(Anim9or.... |
cd477f3f-cb3b-4d78-95c9-54f668c21bba | 1 | public static void main(String[] args) {
// TODO Auto-generated method stub
try {
String content = readFile(args[0], Charset.defaultCharset());
//Compreter.run(content);
MainWindow.init(content);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} |
526e6b4b-5367-494e-9122-7ea7c9184faa | 3 | @EventHandler
public void onEntityDeath(EntityDeathEvent event){
LivingEntity entity = event.getEntity();
if(AnimalUtil.isAnimal(entity)){
if(ExplodeUtil.isAnimalGoingToExplode(entity)){
ExplodeUtil.removeAnimalToExplode(entity);
for(ItemStack itemStack ... |
b7b8b9a9-2e5a-4c93-a415-66c646999851 | 8 | public void destroy(Integer id) throws NonexistentEntityException {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
Motor motor;
try {
motor = em.getReference(Motor.class, id);
motor.getC... |
c2e419bb-09c7-4af2-b47a-666cc16b77a2 | 8 | public S1Interval union(final S1Interval y) {
// The y.is_full() case is handled correctly in all cases by the code
// below, but can follow three separate code paths depending on whether
// this interval is inverted, is non-inverted but contains Pi, or neither.
if (y.isEmpty()) {
return this;
... |
31b046d8-9f5c-40ad-b82d-03e82898d3d6 | 5 | public void convert() throws IOException {
int numberOfRow = 0;
writer.write("\n");
boolean flag = false;
int fullLength = 0;
int columnDataSize = columns.get(0).getDataSize();
for (Column column : columns) {
if (column.getDataSize() != columnDataSize)
... |
008bc210-6bcd-43e1-af4e-d7fff5f2c203 | 1 | public void visiteurPrecedent(){
int index = getVue().getjComboBoxVisiteur().getSelectedIndex()-1;
if(index== -1) index=getVue() .getjComboBoxVisiteur() .getItemCount() -1;
getVue().getjComboBoxVisiteur().setSelectedIndex(index);
} |
1d89a97b-eba1-47c5-9b18-1a4b54198d8d | 3 | @Override
public String execute() throws Exception {
try {
Map session = ActionContext.getContext().getSession();
Campaign camp = (Campaign) session.get("campa");
CampaignDevice campdev = new CampaignDevice(camp, getPlatform());
getMyDao().getDbsession().sa... |
a36666ae-9e85-4851-8d8b-d92bf72c8a01 | 8 | private void addPanelInit() {
addPanel = new JPanel();
addPanel.setLayout(new BoxLayout(addPanel, BoxLayout.Y_AXIS));
generator.createRigidSpace(addPanel, 215);
//Add all the Text and text fields
JLabel nameLabel = generator.createLabel(addPanel, "Meal Name");
final JTextField nameInput = generator.cr... |
33a9ed6e-3509-4d37-ae1c-597e7b395190 | 1 | public void visit_dcmpl(final Instruction inst) {
stackHeight -= 4;
if (stackHeight < minStackHeight) {
minStackHeight = stackHeight;
}
stackHeight += 1;
} |
869ae6ee-6337-48da-afd2-5ecb953c2fcf | 5 | @Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("From ");
if (ipSource != null) {
sb.append(ipSource.getHostAddress());
if (!send) {
sb.append(", ");
sb.append(id);
}
} e... |
bd54c9ec-5b8b-48e1-a74f-5bd584cf8a3c | 5 | public void setSetTMmodeGratingOrder(int[] order){
this.gratingOrderTM = order;
int m = order.length;
if(this.setMeasurementsTMgrating)if(m!=this.numberOfTMmeasurementsGrating)throw new IllegalArgumentException("Number of grating orders entered, " + m + ", is not equal to the number of measureme... |
8c0f1199-8713-4a5c-a1f2-70f2d7383ef8 | 5 | public final int drawProbabilityMiddle(Board board, int totalEval) {
int adjustedScore = totalEval;
int fifty = board.movesFifty;
// If the score says one side is winning but that side does not
// have enough material to win (e.g. only a bishop) return draw
if(adjustedScore > 0 && drawByMaterial(board,WHITE)... |
2ccb0640-618e-4273-8722-edc8b2ed1619 | 9 | protected void writeXML() throws XMLStreamException, JsonParseException, IOException
{
XMLOutputFactory factory = XMLOutputFactory.newInstance();
JsonFactory jsonF = new JsonFactory();
XMLStreamWriter writer = null;
JsonParser jp = null;
try {
jp = jsonF.createJsonParser(is);
writer = factory.cre... |
56f1da4a-ed7b-491c-a8f0-7c017e6fb93a | 8 | public List<String> getMajor() {
Connection conn = null;
ResultSet rs = null;
PreparedStatement ps = null;
List<String> major = Constants.Major;
String asString = (String)Constants.Major.get(0) + "," + (String)Constants.Major.get(1);
try
{
conn = iConomy.getiCoDatabase().getConnection(... |
2ef7213b-dccc-41e3-8c3e-aba7d62e7eb2 | 4 | @Override
public Object getValueAt(int row, int column) {
Object result = null;
Object obj = this.items.get(row);
if(this.columnNames.size() > column) {
ColumnDefinition col = this.columnNames.get(column);
if(col != null) {
if(obj != null) {
try {
result = col.getField().get(ob... |
31d45810-18f2-4088-a69b-4b8c0b5777b7 | 9 | private void recursiveDir(String baseDir, ProgressWorker task)
{
recursiveCount++;
if (!task.getCancelled())
{
task.setMessage("<html><body>Scanning Directory #" + recursiveCount + "<BR>" + (baseDir.length() < 70 ? baseDir : baseDir.substring(0, 70) + "...") + "</body></html>");
File mediaDir = new File(b... |
1b24fee4-58ad-45cf-bbe4-42204aa6a852 | 9 | public static int partition(List<Interval> intervals){
if (intervals == null || intervals.size() == 0) {
return 0;
}
Interval[] times; // array of sorted intervals
int[] countArray = new int[1441]; // There are at most 24*60+1 = 1441
// different times
times = new Interval[intervals.size()];
... |
04d698f8-0f8b-4ba2-adf6-74ef1119ba7c | 7 | @Override
public int compare(Action o1, Action o2) {
this.o1 = o1;
this.o2 = o2;
if (checkHostBackup()) {
} else if (checkHostUpdate()){
} else if (checkCompOrder()) {
} else if (checkBackup()) {
} else if (checkCopy()) {
} else if (checkDelete()) {
} else if (checkPath()) {
}
return currentCompa... |
585aebd1-7307-4b5a-9d4f-0900e8719f7e | 4 | private void setCreditProgramStatus(int status) {
//Номер колонки названия кредитной программы
final int columnName = 0;
//Если выбрана кредитная программа в таблице
if (creditProgramTable.getSelectedRow() != -1) {
//Получаем выбранную кредитную программу
String c... |
b4049c28-60da-4d53-939b-8f3fda495612 | 3 | public static void personalDetails(BufferedReader inp) throws IOException {
PersonalBean personalBean = new PersonalBean();
GenderTbl genderBean = new GenderTbl();
ContactTbl contactBean = new ContactTbl();
LocationTbl locationTbl = new LocationTbl();
locationTbl.setLocationTypeTbl(CachesUtil.getLocationType... |
d72c4a79-004b-4a65-a5ab-73b3b87cffa4 | 6 | final Class305 method444(boolean bool, Class25 class25, Class84 class84) {
try {
if (bool != false)
method424(122, -123, null, -111, 40, 28, -109, null, 76, 127,
-66, 8, -45);
anInt804++;
if ((((Widget) this).anInt705 ^ 0xffffffff) == 0)
return null;
long l = (((long) ((Widget) this).anInt... |
483132ba-4e3a-43d5-8776-1f0fef07758c | 4 | @Override
public Boolean logIn(String username, String password, String type) {
boolean userExists = false;
ResultSet rs;
String status, actualType;
System.out.println("Enter log in...");
try {
PreparedStatement statement = connection
.prepareStatement(
"SELECT * FROM Users "
+ "WHE... |
584976a7-9f57-4d8c-b5d6-773f8cc7b2bc | 5 | public void paint(Graphics g, int xstart, Point2D.Float protPos) {
int xstop = xstart + ScreenController.SCREEN_WIDTH;
int start = (int)(xstart/blockSize);
int stop = (int)(xstop/blockSize) + 2;
if (start < 0) {
start = 0;
}
if (stop >= blocks.length) {
stop = blocks.length - 1;
}
for (int i = ... |
7c679d53-2093-45e6-be24-99d640271e49 | 1 | private void placeTeleporters() {
List<Teleporter> teleports = getNewTeleporters();
for (Teleporter teleport : teleports)
teleport.setDestination(getRandomDestination(teleport, teleports));
} |
74de1cde-edbd-4fe1-b28b-e0f3315ca3a5 | 4 | public T newParticle(){
T particle = null;
try {
particle = ctor.newInstance();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
... |
b9a526ea-58a1-45f8-bc26-f6d053f43698 | 8 | public boolean condicao(String[] expressao){
int end1 = this.verificaVariavel(expressao[1]);
int end2 = this.verificaVariavel(expressao[3]);
double valor1, valor2;
if(end1 == 0){
valor1 = this.getDouble(expressao[1]);
}else{
valor1 = this.vetor[end1].getVa... |
bf2433dc-803b-4d24-800b-f797d718c0da | 2 | @Test
public final void testHashCode() {
int frequency[] = new int[64];
for (int i = 0; i < 1024; i++) {
ActorId id = new ActorId(0);
frequency[id.hashCode() % 64]++;
}
for (int f: frequency) {
assertTrue(f > 1024 / 2 / frequency.... |
a3f99dad-3b0e-4247-88f6-4cb4bae54e78 | 0 | @Override
public <T extends PersistentObject> T read(Class<T> entityClass, Long id) {
return em.find(entityClass, id);
} |
ef2631a4-320a-46af-bead-054150de255d | 0 | public String getCodigo() {
return codigo;
} |
981a806f-1668-40e0-b8d7-9a940836fa59 | 6 | @Override
public void actionPerformed(ActionEvent e) {
// File Chooser anlegen
this.fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
Object source = e.getSource();
if (source == lesen) {
read();
} else if (source == h... |
9416ac70-7c53-445a-b506-f0f09d83e8ed | 4 | public String extractSequence (int len) {
StringBuilder sb=new StringBuilder();
int a,pos=counter-len;
if (pos<0) pos=totalLength-pos;
for (a=0;a<len;a++) {
if (this.get(pos)==true) sb.append("1");
else sb.append("0");
pos++;
if (pos>=totalLength) pos=0;
}
return sb.toString();
} |
23cb954e-eac9-4636-b27d-8eba83543bc8 | 1 | public void setPlayerOffEntity(int x, int y) {
this.mapGrid[x][y].setPawnOn(-1);
if (this.mapGrid[x][y].getType() == Entity.EXIT) {
setValueAt(exitIcon, y, x);
this.isExitHidden = false;
} else {
setValueAt(this.mapGrid[x][y].getIcon(), y, x);
}
} |
e49ca122-273f-468b-b980-6fbd1da3e329 | 2 | private void setLngWindow(double centerLng, double deltaLng) {
double lng1 = centerLng + (deltaLng / 2.0);
double lng2 = centerLng - (deltaLng / 2.0);
if (lng1 > 180 || lng2 < -180) {
this.crosses180thMeridian = true;
} else {
this.crosses180thMeridian = false;
}
lng1 = LatLngTool.normalizeLongitude(l... |
6463ac5e-20be-4690-bdf9-ec7c1608ee2c | 4 | @Override
public void update(String msg) {
char ch = msg.charAt(0);
int i = Integer.valueOf(String.valueOf(ch));
switch (i) {
case 1:
System.out.println(getClass().getName() + "说:天籁啊,真是!");
break;
case 2:
System.out.prin... |
fb48af0b-d4ce-4c58-8f3d-987857c2b0d5 | 4 | private static void inputgraph() throws FileNotFoundException {
// TODO Auto-generated method stub
File f = new File("src/clustering1.txt");
int i;
int j;
for (i = 0; i < 505; i++) {
graph.add(new ArrayList<Integer>());
for(j =0 ; j<505;j++){
edgewieght[i][j] = 15000;
}
... |
130b8052-16f8-4d3c-97b4-8a6df9ec9f82 | 9 | private void emitRenderer(Property syntax, List<AddrModeDecl.Operand> list) {
if ( syntax != null && syntax.type.isBasedOn("String")) {
String format = StringUtil.trimquotes(syntax.value.image);
int max = format.length();
StringBuffer buf = new StringBuffer();
buf... |
9b93d529-5397-41b1-9170-3144f30aeab1 | 1 | private void loadAndCompare(Serializable test, String filename, boolean same) throws Exception {
FileInputStream fis = new FileInputStream("src/resources/" + filename + ".dat");
ObjectInputStream ois = new ObjectInputStream(fis);
Object obj = ois.readObject();
ois.close();
if (sa... |
7b55b295-fba5-45bd-99b5-2757ad2bef49 | 2 | private Area[] buildTicker(boolean outer) {
int barsCount = 11;
AffineTransform toCenter;
AffineTransform toBorder;
AffineTransform toCircle;
Area[] ticker = new Area[barsCount];
Point2D.Double center = new Point2D.Double((double) getWidth() / 2, (double) getHeight() / 2);
double fixedAngle = 2.0 * Math.P... |
2bf698fc-8385-4f8d-8bb4-fcc90aaf2582 | 4 | private static void doCreate() throws MVDToolException
{
try
{
File file = new File( mvdFile );
if ( file.exists() && !file.delete() )
throw new MVDToolException(
"Couldn't delete existing file "+mvdFile);
else
{
MVD mvd = (description==null)?new MVD():new MVD(description);
... |
591b16be-8c22-42e4-be24-804c31e084da | 0 | public void render(Screen screen, int xp, int yp) {
screen.renderSprite(sprite, xp << 4, yp << 4, 0, true);
} |
c9aef942-39df-4d8d-abb0-7c133663c363 | 1 | public void attachDirty(Record instance) {
log.debug("attaching dirty Record instance");
try {
Session session = getSession();
Transaction tr = session.beginTransaction();
session.saveOrUpdate(instance);
tr.commit();
session.flush();
session.close();
log.debug("attach successful");
} catch ... |
5d51996a-0c0f-4892-ad63-ec43ae1ee885 | 8 | private boolean isConnectableInternal(Neighborhood n1, Neighborhood n2) {
if (n1.getCenter().equals(n2.getCenter())) {
return false;
}
final LineSegmentInt seg1 = new LineSegmentInt(n1.getCenter(), n2.getCenter());
if (hasIntersectionStrict(seg1)) {
return false;
}
final double angle1 = Singularity.co... |
7fb19abc-528a-49f7-9607-803b6a9f5d09 | 7 | @Override
public int objHitProcess( Obj o ) {
if ( o.getObjType() == Obj.Type.YUKKURI ){
Body b = (Body)o;
b.giveJuice();
if ( b.isDirty() == true ) {
b.setDirtyFlag(false);
}
if ( rescue ) {
if ( b.isDead() && !b.isCrashed() && !b.isBurned() ){
b.revival();
}
if(b.getFootBakeLev... |
41ce21e7-6aba-4289-9f5f-a0780a9be3a4 | 1 | public int removeQty(int removeQty) {
qty -= removeQty;
if (qty < 1) {
itemType = null;
item = null;
qty = 0;
}
return qty;
} |
a97e607e-bfc4-4d83-b6cb-b921ac421453 | 3 | public void move() //class for ball motion
{
x += xdir; //each time the timer calls the function the x position is either increases or decreased with a set amount of pixels
y += ydir; //same as x
if (x == 0) { //if the ball hits the left side of the screen its motion is changed to the right (+1x... |
a4d912c5-b895-4e6c-bf43-26a7e75b6ee2 | 5 | public int getGreen(int row, int col) {
if (row >=0 && row < rows && col >= 0 && col < columns && grid[row][col] != null)
return grid[row][col].getGreen();
else
return defaultColor.getGreen();
} |
0a6aee60-156b-48b0-8d0a-f0e126989ad6 | 6 | public static int getYear(String s) throws Exception
{
HashSet<String> s2010 = new HashSet<String>();
s2010.add("136"); s2010.add("137"); s2010.add("138"); s2010.add("139");
s2010.add("130"); s2010.add("131"); s2010.add("132"); s2010.add("133"); s2010.add("134");
for(String s2 : s2010)
if(s.indexO... |
93667ed3-8eb6-4f78-bcf1-06c4f38dd751 | 3 | public static void compareDist(FullResult base, FullResult res)
{
System.err.println(Util.append(new StringBuilder(), res.getFilters()));
double sum = 0.0;
double max = 0.0;
for(String key : base.keys()) {
DiscreteDistr d1 = base.get(key);
DiscreteDistr d2 = r... |
9de6ebcc-ea0a-46d9-a985-eecac391d931 | 9 | public void visit(Node root, Point aPoint)
{
if(root.getVisit() == false){ root.setLocation(aPoint); }
try
{
Thread.sleep(Const.SLEEP_TIME);
}
catch (InterruptedException anException)
{
System.err.println(anException);
throw new Run... |
54bc3f60-19ec-4352-b0c6-c450580baa86 | 5 | @Test
public void multiThreadPublish() throws InterruptedException {
final LocalTurtleEnvironment env = getTurtleEnvironment();
final int message_to_sent = 50;
AtomicInteger nosleepMessageCount = new AtomicInteger();
AtomicInteger sleepCountMessages = new AtomicInteger();
tr... |
2a1ba086-e983-42f2-b743-c7c8f88b2285 | 5 | public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> typeToken) {
Type type = typeToken.getType();
Class<? super T> rawType = typeToken.getRawType();
if (!Map.class.isAssignableFrom(rawType)) {
return null;
}
Class<?> rawTypeOfSrc = $Gson$Types.getRawType(type);
Type[] keyAndValueTyp... |
65cb8577-d6a7-439d-9966-9092fe480ebe | 9 | private void serializeFloat(DataOutput out, Object obj) throws IOException {
float v = (Float) obj;
if (v == -1f)
out.write(Header.FLOAT_M1);
else if (v == 0f)
out.write(Header.FLOAT_0);
else if (v == 1f)
out.write(Header.FLOAT_1);
else if (v >... |
04653e22-b848-47d8-8484-01dec4d7839c | 8 | void verify( Node end )
{
Node temp = start;
int pos = graphOffset;
int compared = 0;
while ( temp != null && compared < length )
{
assert temp != end;
Arc a = temp.pickOutgoingArc( version );
if ( a.dataLen() < pos )
{
pos -= a.dataLen();
}
else if ( a.dataLen() == pos )
{
pos =... |
061288f9-1309-4fb8-8bf7-c7906cc7f985 | 2 | @Override
public DemandeMoyen putDemandeMoyen(DemandeMoyen dm)
throws BadResponseException, JSONException {
Representation r = new JsonRepresentation(dm.toJSON());
r = serv.putResource("intervention/" + interId + "/demande", null, r);
DemandeMoyen demande = null;
try {
demande = new DemandeMoyen(new Js... |
48b2049b-0972-460b-94a2-96072394671f | 4 | private void drawTiles(int imageWidth, int imageHeight, Graphics g)
{
char Letter = 'A';
// Draws the board squares onto the panel
for(int i = 0; i < boardSize; i++, Letter++)
{
for(int j = (boardSize-1); j >= 0; j--)
{
if(j % 2 == i % 2)
{
g.setColor(Color.blue);
g.fillRect((getWi... |
11f40345-86e7-43f7-a8d2-b3f4b58d17c1 | 9 | public static String processCommand(ArrayList<String> commandArray, ArrayList<City> cities, ArrayList<Mines> mines) {
String expression = null;
if (commandArray.get(0).toLowerCase().equals("feed") && commandArray.size() == 5) {
expression = processFeed(commandArray, cities, mines);
} else if (commandArray.get... |
3efae784-643d-45b9-aaf4-160ff056242f | 5 | private void initComponent() {
JLayeredPane layeredPane = new JLayeredPane();
getContentPane().add(layeredPane, BorderLayout.CENTER);
lblNick.setFont(new Font("Dialog", Font.PLAIN, 15));
lblNick.setBounds(12, 12, 41, 19);
layeredPane.add(lb... |
9e254496-0793-4275-9c17-829db1735a98 | 8 | public URL formatUrl(String url) {
URL formatedUrl = null;
if (url.startsWith("file:")) {
if(url != "file:./lab5/404.html" && url != "file:./lab5/history.html") {
url = url.substring(10);
return formatUrl(url);
}
} else if (!url.startsWith("http://")) {
if (url.startsWith("www.")) {
url ... |
24b12549-16e0-4aa3-aac6-9ed9ee2cdd90 | 3 | public void testFormatSuffixPlural3() {
try {
builder.appendSuffix(null, "");
fail();
} catch (IllegalArgumentException ex) {}
try {
builder.appendSuffix("", null);
fail();
} catch (IllegalArgumentException ex) {}
try {
... |
7e4d468a-c0d6-4611-8b71-db845b96e465 | 9 | public int GetIncome(String location){
int income = 0;
WAQuery query = engine.createQuery();
query.setInput(location+" amount of per capita income");
try {
WAQueryResult queryResult = engine.performQuery(query);
if (queryResult.isError()) {
} else if (!queryResult.is... |
67760cf1-edc1-4e56-b2ac-a70f9fbfac20 | 6 | public static void main(String args[]) {
int inch, feet; // holds the number of gallons
double meters; // holds the number of liters
inch=0;
feet=0;
meters=0;
for ( feet = 0; feet < 13; feet++) {
for ( inch = 0; inch < 13; inch++) {
if ( inch == 0 && feet > 0 ) {
meters = (feet * 12) *... |
1a1d6763-0568-44cd-bdb1-06f5176c3c22 | 0 | public synchronized void setValue(double value) {this.value = value;} |
976b6ec2-2664-437d-9d47-75d3c6b825db | 4 | public void actionPerformed(ActionEvent e) {
if(e.getSource() == finish) {
addGame();
mathGame.getCardPanel().hideCards(); // Hide cards until next player joins
mathGame.showMenu(MathGame.Menu.GAME); // Go to the game (but should it wait?)
Thread waitForPlayer = new Thread() {
public void run() {
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.