method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
b06f1929-0eee-4963-9291-58a93dfc17f8 | 5 | public Writer write(Writer writer) throws JSONException {
try {
boolean commanate = false;
Iterator keys = this.keys();
writer.write('{');
while (keys.hasNext()) {
if (commanate) {
writer.write(',');
}
... |
fb11fc2d-4d1f-4cad-999f-f84803b193d4 | 0 | public void synchonizeDefaultMenuItem() {
OutlinerSubMenuItem openMenu = (OutlinerSubMenuItem) GUITreeLoader.reg.get(GUITreeComponentRegistry.OPEN_MENU_ITEM);
OpenFileMenuItem openMenuItem = (OpenFileMenuItem) openMenu.getItem(0);
openMenuItem.setProtocol(getDefault());
OutlinerSubMenuItem importMenu = (Outl... |
4983f48b-1b50-4bee-a070-c43ec71dc764 | 4 | private static String generateKey() {
Random r = new Random();
long maxNumber = 4294967295L;
long spaces = r.nextInt( 12 ) + 1;
int max = new Long( maxNumber / spaces ).intValue();
max = Math.abs( max );
int number = r.nextInt( max ) + 1;
long product = number * spaces;
String key = Long.toString( produ... |
7fdb8592-0364-42ba-acf9-694e81d29f51 | 1 | private ItemSelectionListener global() {
return new ItemSelectionListener() {
@Override
public void itemSelectionChanged( ItemSelectionEvent event ) {
for( ItemSelectionListener listener : getListeners() ) {
listener.itemSelectionChanged( event );
}
}
};
} |
40ced1bb-02f3-4a18-839d-338aaf515f2c | 0 | public StringPickerGenerator(String tableName, String columnName, List<String> alternatives) {
super(tableName, columnName);
this.alternatives = alternatives;
} |
3e8d69d7-7ee2-4dfc-a977-b7bdf38c0acd | 5 | final void method3954(int i, Class310_Sub2 class310_sub2) {
method3956((byte) -56, class310_sub2);
if (aBooleanArray9786[((DirectxToolkit) this).anInt8175]
== !((Class310_Sub2) class310_sub2).aBoolean6334) {
((DirectxToolkit) this).anIDirect3DDevice9810.SetSamplerState
(((DirectxToolki... |
6654c1fb-105c-44c1-9592-b6ae7b0a3b6d | 0 | public ConfigFile()
{
//initialize hashtable
configSections = new Hashtable();
//read the config file
ReadConfigFile();
} |
6ae656f8-4efa-4bf9-90ef-2c2fbffee189 | 0 | public void sendtoserver(String s) {
String title = "[pvpϵͳ]";
this.log.info(title + s);
} |
28294959-5864-45d1-9207-c4eaf81bdc60 | 0 | public static Secteur selectOne(EntityManager em, String code_sec) throws PersistenceException {
Secteur unSecteur = null;
unSecteur = em.find(Secteur.class, code_sec);
return unSecteur;
} |
22db99ee-544c-46e9-ad0c-512f90f112bf | 3 | @Test
public void emptyResultsIfGettersOutOfBounds()
{
setupHighScoreTest();
assertTrue(high.getNameByRank(-1).equals("") &&
high.getScoreByRank(-1) == 0 &&
high.getNameByRank(3).equals("") &&
high.getScoreByRank(3) == 0);
} |
282e4568-7e42-4853-830f-9beaa3af5067 | 3 | public <ObjectType, SpriteType extends Sprite<ObjectType>> SpriteType getSpriteOfTypeFor(
Class<SpriteType> type, ObjectType object) {
if (object == null) {
return null;
}
for (SpriteType sprite : getSpritesOfType(type)) {
if (object.equals(sprite.getObject())) {
return sprite;
}
}
return null... |
bd35e4ab-5e31-4861-a31a-3bde2d14a2e7 | 7 | public static boolean NTfuncDef() throws IOException {
boolean success = true;
success = ErrorRecovery(NonTerminal.funcDef);
switch (lookahead) {
case ID:
case INTEGER:
case REAL:
if (!NTfuncHead())
success = false;
if (!NTfuncBody())
success = false;
if (!match(TokenType.SEMICOLON))
... |
fa9ecce8-9bbe-449c-8ddd-0f40d66e4c4b | 2 | public void reachableReference(Reference ref, boolean isVirtual) {
String clName = ref.getClazz();
if (clName.charAt(0) == '[')
/* Can't represent arrays */
return;
ClassIdentifier ident = getClassIdentifier(clName.substring(1,
clName.length() - 1).replace('/', '.'));
if (ident != null)
ident.reach... |
889fb10c-b65f-4328-9bcc-699ffc855084 | 7 | @Override
protected double valueMove(Move m, GameBoard board, int lookahead) {
if (m instanceof NoMove) return 0;
else if (m instanceof BuyDevCard) return 1;
else if (m instanceof ProposeTrade || m instanceof FulfillTrade) return 2;
else if (m instanceof BuildRoad) return 3;
else if (m instanceof BuildSettle... |
1cf0f4af-3270-4cae-b2a0-f69c9fe8586a | 8 | @Test
public void warandPeaceTest() throws Exception{
DLB dict = new DLB();
File warPeace = new File("warandpeace.txt");
StringTokenizer tk;
String str;
String nxt;
boolean allContained = true;
if(warPeace.isFile()){
BufferedReader wpReader = new B... |
adeac073-97f6-4d95-8956-89ed2f5a445d | 9 | public static Class getWrapper(Class primitive) {
if ( ! primitive.isPrimitive()) {
return primitive;
}
Class result = null;
if ( primitive.equals(int.class)) {
result = Integer.class;
} else if ( primitive.equals(long.class)) {
result = Long.c... |
fdb5a17b-a887-4c51-bc06-360960f85291 | 2 | public static String vectorCaddieDeletionToHTML(Vector<Caddie> rs){
if (rs.isEmpty())
return "";
String toReturn = "<TABLE BORDER='1' width=\"1000\">";
toReturn+="<CAPTION>Ces places ne sont pas réservables car la représentation a déjà eu lieu :</CAPTION>";
toReturn+="<TR>";
toReturn+="<TH> <i>Reservatio... |
8c3b7f4e-dd85-446c-9670-e1231609f9a0 | 9 | public void moveTo(FATFolder newParent) throws IOException {
if (newParent == null)
throw new IllegalArgumentException("Bad new parent");
if (isRoot())
throw new IOException("Cannot move the root");
//only one move or delete at once
freeze();
try {
... |
cbf7c0bb-716e-4728-bcf1-ec79a543c4b2 | 0 | public static int putMap(HashMap<String,String> map,String key, String value){
map = new HashMap<String,String>();
map.put(key, value);
counter_put++;
return counter_put;
} |
2eaede38-73b2-49dd-ae32-99fb80bd16e3 | 5 | public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] nums = new int[n];
for (int i = 0; i < n; i++) {
nums[i] = scanner.nextInt();
}
Arrays.sort(nums);
int minDiff = Integer.MAX_VALUE;
... |
5d518100-cda6-4537-bf3d-927e23eba853 | 2 | public Track getTrack(String name) {
for(int x = 0; x<tracks.size(); x++) {
if(tracks.get(x).getName().matches(name))
return tracks.get(x);
}
return null;
} |
84446db0-08f8-4ce0-97d5-dbf9c67bb464 | 9 | private void setNextObject() {
if (!iter.hasNext()) {
nextObject = null;
iter = null;
return;
}
Object o = iter.next();
try {
if (o instanceof File) {
File file = (File) o;
if (file.isDirectory()) {
ArrayList<Object> l = new... |
fc8d47da-5b6a-4deb-9968-74effff840f2 | 7 | public InfoPanel() {
super(new BorderLayout());
Box verticalBox = Box.createVerticalBox();
Box center = Box.createHorizontalBox();
center.add(Box.createHorizontalGlue());
center.add(new JLabel(new ImageIcon(DataStorage.mainLogo.getImage().getScaledInstance(
DataS... |
0d782e4a-6af9-4060-b436-73bab4c59f71 | 5 | private void btnEnterRecordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEnterRecordActionPerformed
foundIndex = NOT_FOUND;
partNo = this.txtNewProdNo.getText();
partDesc = this.txtNewProdDesc.getText();
try {
partPrice = Double.parseDouble(this.txtNe... |
1cb26acb-a977-4aab-aedd-6157f70003c7 | 7 | public int findElement(int array[], int element)
{
int n = array.length;
if(n == 1)
return array[0];
int middle = (n-1)/2;
//best cases!
if(element == array[middle])
return array[middle];
if(n==2)
return array[n-1];
//search on RIGHT block : for(int i = middle+1; i <= n; i++)
... |
25d7b831-5e9c-4f71-94c8-fd82bac89819 | 5 | @Override
public boolean onCommand(CommandSender sender, Command cmd, String label,
String[] args) {
if(cmd.getName().equalsIgnoreCase("god")) {
if(sender instanceof Player) {
Player p = (Player) sender;
PlayerUtil pu = new PlayerUtil(p);
if(pu.hasPermission("Nostalgia.Command.god", PermissionType.... |
a04d1b82-8981-4239-9132-1b8bf212de5a | 5 | protected synchronized boolean broadcastMessage(Message msg){
if(msg == null)
return false;
msg.setSourceID(this.auctioneerID);
msg.setDestinationID(Message.TO_ALL_BIDDERS);
msg.setAuctionID(this.auctionID);
int tag = -1;
int nBidders = bidders.size();
if( msg instanceof Mess... |
cd75a829-ba39-49fd-8d2c-0a7f9cc40965 | 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... |
1eca2040-3266-4a84-86f6-d858bf2be9e9 | 1 | public ObjektNode[] getChilds(ObjektNode paramObjektNode)
throws XmlRpcException, IOException
{
Vector localVector = (Vector)Client.getXmlRpcClient().execute("TreeHandler.getChilds",paramObjektNode.getParentId(), paramObjektNode.getArt().toString(), Boolean.valueOf(false), null, null);
ObjektNode[... |
223c3b74-8109-4bb1-8268-a85c22c6b531 | 3 | @Override
public void sendUsageImpl(CommandSender sender) {
if (!(sender instanceof Player)) return;
sender.sendMessage(EdgeCore.usageColor + "/cash info");
sender.sendMessage(EdgeCore.usageColor + "/cash give <user> <amount>");
sender.sendMessage(EdgeCore.usageColor + "/cash donate <amount>");
User u ... |
0ac1c346-8011-426f-87a7-1cccf1ca5931 | 6 | @Override
public long put(long priority, int delaySeconds, int timeToRun, byte[] data) {
if (data == null) {
throw new BeanstalkException("null data");
}
if (priority > MAX_PRIORITY) {
throw new BeanstalkException("invalid priority");
}
long jobId = -1;
Request request = new Request("put " + priority... |
9b104136-5ef4-431f-9ea9-504cf989ef32 | 0 | public String getSearchURLArgs()
{
_read.lock();
try
{
return _searchURLArgs;
}
finally
{
_read.unlock();
}
} |
27e00f9f-9c1e-4acc-8558-6c330f49ca97 | 8 | public static void handleMouse(){
MouseEvent event;
int mx = Mouse.getEventX();
int my = Mouse.getEventY();
while(Mouse.next()){
if(Mouse.getEventButton() == 0){
if(Mouse.isButtonDown(0)){
if(game.duringPass){
for(Player p : game.getAllPlayers()){
if(p.getDisplay().getRect().contains... |
dad43db9-7936-40a7-bdb9-b8bd59a37bd2 | 8 | public List<MorrisIntersection> getNeighbor() {
List<MorrisIntersection> ret = new ArrayList<MorrisIntersection>();
if (hasLeft()) {
ret.add(left());
}
if (hasRight()) {
ret.add(right());
}
if (hasUp()) {
ret.add(up());
}
if (hasDown()) {
ret.add(down());
}
if (this.hasSkewLeftUp()) {
... |
539f0d48-7891-4123-8f44-a1d31b2fdc6d | 6 | String getMenuItemText(String item) {
boolean cascade = item.equals("Cascade");
boolean mnemonic = mnemonicsButton.getSelection();
boolean accelerator = acceleratorsButton.getSelection();
char acceleratorKey = item.charAt(0);
if (mnemonic && accelerator && !cascade) {
return ControlExample.getResourceStrin... |
a7714ecf-8dd9-4f5a-b70a-56d094853ce3 | 0 | public Address(String City, String Sector, String Calle, String HouseNumber,
String PostalCode, String country, String region) {
this.City = City;
this.Sector = Sector;
this.Calle = Calle;
this.HouseNumber = HouseNumber;
this.PostalCode = PostalCode;
this.country=country;
this.region="";
} |
5dd5a828-6f13-402a-a267-aae80a317dca | 5 | public WeaponEditor(String name) {
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
setTitle("Weapon Editor");
setBounds(100, 100, 600, 475);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);
con... |
a3ffd7d0-70a3-406b-8e9a-cc53acf6381b | 1 | public void testWithField2() {
DateTime test = new DateTime(2004, 6, 9, 0, 0, 0, 0);
try {
test.withField(null, 6);
fail();
} catch (IllegalArgumentException ex) {}
} |
b80c6f76-1bc8-4e6b-a11c-32aa8f4bbd25 | 8 | public static Calendar parseTimestamp(String timestamp) {
// Timestamp pattern
Pattern p1 = Pattern
.compile("\\w{3}, \\d{1,2} \\w{3} \\d{4} \\d{2}:\\d{2}:\\d{2} [+-]{1}\\w{4}");
Pattern p2 = Pattern
.compile("\\w{3}, \\d{1,2} \\w{3} \\d{4} \\d{2}:\\d{2}:\\d{2} \\w{3}[+-]{0,1}\\d{0,2}[:]{0,1}\\d{0,2}");
... |
9ec8a96a-27f1-4a35-b343-1179daaecbe7 | 5 | public void initialize(String filePath){
_rawData = new LinkedList<String>();
patternEncoderUtil = new PatternEncoderUtil();
try {
fileReader = new FileReader(filePath);
_bufferedReader = new BufferedReader(fileReader);
while ((sCurrentLine = _bufferedReader.r... |
2e8d38a7-a738-4315-bb68-0ad3a9643554 | 0 | public CmdResetExecutor(SimpleQueues plugin) {
this.plugin = plugin;
} |
1633e8f8-121c-4474-9c19-ed855f53cf25 | 5 | @Test
public void TestaaYlhaaltaAlasEste() {
rakentaja = new Kartanrakentaja(10, 6);
rakentaja.asetaEste(5, 3);
rakentaja.asetaEste(5, 4);
rakentaja.asetaEste(5, 2);
char[][] kartta = rakentaja.getKartta();
Solmu aloitus = new Solmu(0, 3);
Solmu maali = new So... |
53c3292b-a670-4465-a64a-0d6ea5f80a31 | 7 | public void paint1(Graphics g) {
//g.setColor(Color.RED);
//g.fillRect(0, 0, getWidth(), getHeight());
// Muestra en pantalla el cuadro actual de la animación
g.drawImage(background, 0, 0, this); // Imagen de background
if (pelota != null && pelota.getImagenI() != null) {
... |
440956cf-e727-4893-8ddf-56f84ec5348f | 9 | @Override
public int[] getInts(int par1, int par2, int par3, int par4)
{
deepOcean = BiomeGenBase.deepOcean.biomeID;
mushroomIsland = BiomeGenBase.mushroomIsland.biomeID;
int i1 = par1 - 1;
int j1 = par2 - 1;
int k1 = par3 + 2;
int l1 = par4 + 2;
int[] ain... |
75fab6d6-a2b9-4243-9720-9ef70599f3df | 5 | protected boolean verificarConvergencia() {
boolean converge = false;
for (int i = 0; i < this.matriz.linhas && !converge; i++) {
for (int j = i + 1; j < this.matriz.linhas && !converge; j++) {
converge = criterioLinhas();
if(!converge) {
trocarLinhas(i,j);
... |
62a64f4f-f9e7-4686-8c25-e55ba8d7ebb4 | 8 | public void omitLessFreq() {
if (name == null) return; // Illegal
int threshold = n_words[0] / LESS_FREQ_RATIO;
if (threshold < MINIMUM_FREQ) threshold = MINIMUM_FREQ;
Set<String> keys = freq.keySet();
int roman = 0;
for(Iterator<String> i = keys.iterator(); i.... |
59c155bc-6855-4e7a-9dbd-8f43c5045edf | 1 | public static void spawnPossessedItem (Location loc, int amount, ItemStack stack) {
int i = 0;
while (i < amount) {
Skeleton possessedItem = (Skeleton) loc.getWorld().spawnEntity(loc, EntityType.SKELETON);
possessedItem.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESIS... |
5a4965f6-e26d-408f-a1ee-73f879413dbe | 6 | private void insertFixup(Node z) {
while(z.parent.color == RED){
if(z.parent.equals(z.parent.parent.left)){
Node y = z.parent.parent.right;
if(y.color == RED){
z.parent.color = BLACK;
y.color = BLACK;
z.parent.parent.color = RED;
z = z.parent.parent;
}else{
if(z.equals(z.parent... |
de6d1595-02db-4aff-be88-2aa85968e488 | 9 | private void BtGravarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BtGravarActionPerformed
if (camposobrigatoriospreenchidos()) {
if (JOptionPane.showConfirmDialog(null, "Tem certeza que deseja realmente Gravar os dados deste fornecedor?", "Confirmar", JOptionPane.YES_NO_OPTION)... |
323fe4d4-e218-4310-ba58-20714f348cfb | 6 | public int appendTo(StringBuilder sb, boolean tiny, boolean noneIfEmpty) {
int num = 0;
for (int i = 0; i < total.length; i++) {
int t = total[i];
if (t != 0) {
if (num++ > 0) {
sb.append(", ");
}
StatT stat = S... |
bac05f2e-4c40-4f64-9a17-780691e87bb6 | 8 | @SuppressWarnings("unchecked")
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case statePackage.STATE__PLAYERS:
getPlayers().clear();
getPlayers().addAll((Collection<? extends Player>)newValue);
return;
case statePackage.STATE__COUNTRY_STATE:
((EStructuralFea... |
cd2510f0-7703-4d72-9e6a-0f7c136f90e6 | 7 | static void dradb2(int ido, int l1, float[] cc, float[] ch, float[] wa1,
int index){
int i, k, t0, t1, t2, t3, t4, t5, t6;
float ti2, tr2;
t0=l1*ido;
t1=0;
t2=0;
t3=(ido<<1)-1;
for(k=0; k<l1; k++){
ch[t1]=cc[t2]+cc[t3+t2];
ch[t1+t0]=cc[t2]-cc[t3+t2];
t2=(t1+=ido)<<1... |
97b8f954-4539-42af-bd92-2a9d1d0f5f1c | 7 | public void sendBundledMessages(final Message[] buf, final int read_index, final int available_msgs) {
int max_bundle_size=transport.getMaxBundleSize();
byte[] cluster_name=transport.cluster_name.chars();
int start=read_index;
final int end=index(start + available_msgs-1);... |
d9197790-eed2-46dc-aa98-7f63dde75559 | 2 | public void method(String str) throws MyException,MyException1
{
if(null == str)
{
throw new MyException("传入的字符串参数不能为null");
}
else if("hello".equals(str))
{
throw new MyException1("输入的内容是:hello !");
}else
{
System.out.println(str);
}
} |
11616372-cf43-4b70-af93-c0e2b069917c | 1 | public void printMessages()
{
for (String s : list )
{
System.out.println(s);
}
} |
18341ac4-1750-48e9-8d43-2a4bdc70e8bc | 7 | @Override
public boolean invoke(MOB mob, List<String> commands, Physical givenTarget, boolean auto, int asLevel)
{
Physical target=mob;
if((auto)&&(givenTarget!=null))
target=givenTarget;
if(target.fetchEffect(this.ID())!=null)
{
mob.tell(mob,target,null,L("<T-NAME> <T-IS-ARE> already affected by @x1.",... |
858a2cb8-36cb-4012-a8a6-2976c9a9242e | 3 | public static void newProcessingFormat(Object[] Fieldsin) {
//Filed(0) = Nombre de campo
//Field(s%4=0) = VariableComp1 = [X:|S:|C:|E:][N:|H:]NAME_op1
//Field(s%4=1) = operation = '==' '!=' '<' '>' '>=' '<='
//Field(s%4=2) = VariableComp2 = [X:|S:|C:|E:][N:|H:]NAME_op2
//Fiel... |
deadfc9e-54c8-4638-b1e4-3bf0ab0fa1e0 | 7 | public ComputStdMethodDouble(double []v){
if (null == v || 0 == v.length){
mean = median = stddev = 0;
min = max = 0;
}else if (1 == v.length){
mean = median = stddev = v[0];
min = max = v[0];
}else{
double sum = v[0],sqSum=0;
min =v[0];
max = v[0];
for (int i=1;i<v.length;i++) {
... |
5712f09d-55e9-4034-b9f2-a77e39154fd5 | 1 | public void incluirNoInicio(ContaCorrente conta)
{
for (int i=this.capacidade - 2; i > 0; i ++)
this.aContas[i+1] = this.aContas[i];
this.aContas[0] = conta;
this.quantasContas ++;
} |
c32fa131-6611-4b2a-8093-28cbdce48683 | 7 | private TreeNode getSearchedNodes(String searchTxt) {
final DefaultMutableTreeNode master = new DefaultMutableTreeNode();
final Widget[] widgets = Widgets.getLoaded();
outer:
for (final Widget widget : widgets) {
if (widget.getChildrenCount() > 0) {
final WidgetChild[] children = widget.getChildren();
... |
6b9b1092-a1b6-4148-9fc8-adf4c58f1a99 | 5 | public static boolean isPrime(int x) {
if (x == 2) {
return true;
}
if (x % 2 == 0 || x == 1) {
return false;
}
for (int i = 3; i * i <= Math.abs(x); i += 2) {
if (x % i == 0) {
return false;
}
}
return true;
} |
6366ba7e-4dcb-43bc-afc2-fade3eb79277 | 8 | public static List<Integer> findTetrahedralChiralCenters(Molecule molecule) {
List<Integer> chiralCenterIndices = new ArrayList<Integer>();
MoleculeSignature molSig = new MoleculeSignature(molecule);
List<String> signatureStrings = molSig.getVertexSignatureStrings();
for (int i = 0; i < ... |
3510f758-c2ae-4d05-bd9a-a5690d125d9b | 5 | public java.awt.Component getTableCellEditorComponent(
javax.swing.JTable jtable,
Object value,
boolean isSelected,
... |
725161a2-ee4f-4e09-8f6b-98ac823cb70c | 2 | private void adjustBounds() {
if (mStorageCount > 0) {
Rectangle bounds = mStorage[0].getBounds();
mBounds.x = bounds.x;
mBounds.y = bounds.y;
mBounds.width = bounds.width;
mBounds.height = bounds.height;
for (int i = 1; i < mStorageCount; i++) {
mBounds.add(mStorage[i].getBounds());
}
} e... |
42e98589-ef0b-4d68-8585-3dbdf6a0d472 | 8 | protected void compareDatasets(Instances data1, Instances data2)
throws Exception {
if (!data2.equalHeaders(data1)) {
throw new Exception("header has been modified\n" + data2.equalHeadersMsg(data1));
}
if (!(data2.numInstances() == data1.numInstances())) {
throw new Exception("number of instan... |
93c092ca-5595-450c-9dd9-c6adcb93b143 | 9 | public static Stack<Point> getPath(Point home, Point size, ArrayList<Point> dirts, ArrayList<Point> bumps)
{
State cur = new State(home, null,new HashSet<Point>(dirts),new HashSet<Point>(bumps));
//Shearch for the path.
Stack<State> frontier = new Stack<State>();
HashSet<State> visited = new HashSet<State>(... |
1a71adcc-8473-489f-a7ba-97c8ff7dc9a0 | 8 | static Gain parseGain(final int algorithmNumber, final byte[] gainParameters) throws ParseException {
Gain gain;
switch (algorithmNumber) {
case 0:
gain = null;
break;
case 1:
gain = ToneParser.parse(gainParameters);
... |
9fabbb99-cbfe-40d0-9510-852aac530028 | 1 | public void abortCommunication(final SubLWorker worker) throws IOException {
final Integer id = worker.getId();
if (id.intValue() < 0) {
//@note serial communications cannot be canceled right now
return;
}
try {
final String command = "(fif (" + "terminate-active-task-process"
... |
a66e6c9f-d65a-4d7f-962d-8b32c586e6d2 | 3 | public static boolean isTruncatable(String num) {
for (int i = 1; i < num.length(); i++) {
if (!isPrime(Integer.parseInt(num.substring(0, i)))
|| !isPrime(Integer.parseInt(num.substring(i)))) {
return false;
}
}
return true;
} |
2151bddb-1514-4967-8636-1b02bdf7a72e | 6 | @Override
public void actionPerformed(ActionEvent e) {
if(e.getSource().equals(btnNextPanel1)){
cardLayout.show(frame.getContentPane(), "Panel2");
}
else if(e.getSource().equals(btnNextPanel2)){
cardLayout.show(frame.getContentPane(), "Panel3");
}else if(e.getSource().equals(btnNextPanel3)){
c... |
1ec7e83c-db0d-4db9-884e-de49efdfd12e | 5 | public AbbreviationAlignmentContainer<AbbvGapsHMM.Emissions, AbbvGapsHMM.States> findMostProbablePathBackwards(Acronym acronym){
int sPos = _sParam.getRangeEnd();
int lPos = _lParam.getRangeEnd();
int state = States.S.ordinal();
int stringPosS = -1;
int stringPosL = -1;
if(_evalMat.at(0, 0, States.S.ordi... |
f4c906f0-51d2-4398-ac1c-91faf36c15d8 | 4 | public void setInstruments(int percusInstr) {
switch(percusInstr) {
case 0: // Rock
this.bass = "[acoustic_bass_drum]";
this.snare = "[acoustic_snare]";
this.openHiHat = "[open_hi_hat]";
this.closedHiHat = "[closed_hi_hat]";
this.hiTom = "[hi_tom]";
this.hiMidTom = "[hi_mid_tom]";
this.... |
ec0ea037-fe98-4cb4-9ccd-efe47cb728f8 | 7 | public Element handle(FreeColServer server, Player player,
Connection connection) {
ServerPlayer serverPlayer = server.getPlayer(connection);
Unit carrier;
try {
carrier = player.getFreeColGameObject(carrierId, Unit.class);
} catch (Exception e) {
... |
cbec2022-c7a2-4386-937a-7a442429f064 | 0 | public void setResultFilePath(String resultFilePath) {
this.resultFilePath = resultFilePath;
} |
c613dcad-d803-4b9d-b839-2ee4300e2a68 | 5 | private boolean roomIconClicked(Point mousePos){
for(int i = 0;i<rooms.size();i++){
if(
mousePos.x > getRoomIconPos(i).x &&
mousePos.x < getRoomIconPos(i).x+rooms.get(i).getIconSize().x &&
mousePos.y > getRoomIconPos(i).y &&
mousePos.y < getRoomIconPos(i).y+rooms.get(i).getIco... |
18065a21-210b-45a3-9b9d-5ce9d65b5b1a | 6 | protected int[] besterZug(int[] aktuellePosition,
ArrayList<int[]> moeglicheZuege, String[][] spielfeld) {
int[] zielPosition = getAktuelleZielPosition(spielfeld);
double aktuellerAbstand = berechneAbstand(aktuellePosition,
zielPosition);
int[] bestePosition = { aktuellePosition[0], aktuellePosition[1] };
... |
99f2ba6a-45d4-4238-af9d-a00d662ecd99 | 4 | public void gameLoop() {
long lastTick = System.nanoTime();
while (true) {
try { Thread.sleep(4); } catch (Exception e) {}; // pause a bit so that we don't choke the system
double deltaTime = (double)(System.nanoTime() - lastTick) / 1_000_000_000.0;
lastTick = System.nanoTime();
// Update multiple times... |
3ed277f3-c0d6-4384-b6ec-4ae07523e407 | 2 | public List<String> listServerIds() throws Exception
{
CloudStackApiClient client = new CloudStackApiClient(LIST_VIRTUALMACHINE, apiKey, secretKey, apiUrl);
String response = client.execute();
if (containsErrorMessage(response))
{
throw new Exception("Error retrieving Servers. Response:" + getErrorMessage(... |
c55e2165-94d4-45a0-bfa7-5769677ee1c0 | 5 | @Override
public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
{
String htmltext = "";
QuestState st = player.getQuestState(qn);
if (st != null && Util.isDigit(event))
{
int score = Integer.parseInt(event);
if (SCORES.containsKey(score))
{
int crystal = SCORES.get(score).getC... |
96702002-dcf1-4ae0-989e-c078281bb678 | 7 | */
public void centerVertical(FastVector nodes) {
// update undo stack
if (m_bNeedsUndoAction) {
addUndoAction(new centerVerticalAction(nodes));
}
int nMinX = -1;
int nMaxX = -1;
for (int iNode = 0; iNode < nodes.size(); iNode++) {
int nX = getPositionX((Integer) nodes.elementAt(iNode));
if (nX < ... |
63acfc1e-0dc1-4ca5-82cf-4462e49d6292 | 6 | public float arg() {
final float PI = (float)Math.PI;
if (x == 0) {
if(y < 0) {
return -PI/2;
} else if (y > 0) {
return PI/2;
}
throw new IllegalArgumentException("The argument of the zero vector is undefined.");
... |
4c2523f6-52e5-48a0-9a35-3dbf4c25ffcd | 2 | public boolean hasStatus(UnitStatus.Type statusType) {
for (UnitStatus status : statuses) {
if (status.getType() == statusType) {
return true;
}
}
return false;
} |
2773ffe8-2280-4b97-b1c5-763bb2f7a3e3 | 3 | @Override
public void run() {
long beforeTime, timeDiff, sleep;
beforeTime = System.currentTimeMillis();
while (gameLogic.getBase().getHealth() > 0) {
gameLogic.moveEnemies();
gameLogic.checkCollisions();
repaint();
timeDiff = System.currentTimeMillis() - beforeTime;
sleep = Definitions.simulation... |
baa181b2-cd16-428e-bfb5-9301eb1ed1da | 4 | public String getHumanPropValue(String name, String prop)
throws IOException {
if (name.isEmpty())
return null;
if (humanProp == null)
setHumanProp();
if (humanProp == null)
throw new NullPointerException();
LinkedHashMap<String, String> human = humanProp.getHuman(name);
if (human == null)
retu... |
b9cbd10b-5ed5-411d-8fcd-cf2b9fef42e0 | 7 | public static void main(String[] args){
// Socket which will connect to the engine.
Socket socket = null;
// Reader to read packets from engine
BufferedReader inStream = null;
// Convenience wrapper to write back to engine
PrintWriter outStream = null;
// port number... |
5f2d78c9-16b5-4390-ac4b-7fc625ec1358 | 4 | private Image findGameElementImage(Element element) {
if (element instanceof IdentityDisc) {
return identitydisc;
} else if (element instanceof LightGrenade) {
if (!((LightGrenade) element).isActive()
&& !((LightGrenade) element).isExploded())
return lightgrenade;
}
return null;
} |
00fe1e4a-bb0d-4b74-a176-06ba0a8a8c65 | 8 | void output(int code, OutputStream outs) throws IOException {
cur_accum &= masks[cur_bits];
if (cur_bits > 0)
cur_accum |= (code << cur_bits);
else
cur_accum = code;
cur_bits += n_bits;
while (cur_bits >= 8) {
char_out((byte) (cur_accum & 0xff), outs);
cur_accum >>= 8;
cur_bits -= 8;
}
... |
7d6165a1-2868-4da9-b309-4c5bcb025ecf | 2 | @Override
public void setForeground(Color foregroundColor) {
assert foregroundColor != null;
if (this.foregroundColor != null && this.foregroundColor.getRGB().equals(foregroundColor.getRGB())) {
return;
}
super.setForeground(foregroundColor);
this.foregroundColor = foregroundColor;
} |
64818cf8-c674-4235-b2aa-405ae851bdca | 6 | protected void paintFocus(Graphics g, AbstractButton b,
Rectangle viewRect, Rectangle textRect,
Rectangle iconRect)
{
boolean divider = b.getName() == null ? false :
b.getName().equals("dividerButton");
if(b.getModel().isPressed() || mouseOver ||... |
19e88862-5a30-465d-82d7-c16dbc074f09 | 4 | public Attacks removeMin() {
if ( _heap.size() == 0 )
return null;
//store root value for return at end of fxn
Attacks retVal = peekMin();
//store val about to be swapped into root
Attacks foo = _heap.get( _heap.size() - 1);
//swap last (rightmost, deepest) leaf with root
swap( 0, _heap.size() - 1 );
... |
41b1c40c-cc2f-4fb9-a376-1d610dde4761 | 1 | public Deliver OnDeliver() {
if (this.LoginResult.ErrorCode == 0) {
return this.pconnect.OnDeliver();
} else {
return null;
}
} |
9454ef79-dd61-4843-8e81-8d4c1081c044 | 1 | public void testInvalidObj() {
aDateTime = getADate("2000-01-01T00:00:00");
try {
cYear.compare("FreeBird", aDateTime);
fail("Invalid object failed");
} catch (IllegalArgumentException cce) {}
} |
b05e218f-6388-47cb-aef3-e23ba4ea3f99 | 6 | void betting() throws Exception
{
System.out.println("Betting begins. ");
System.out.println("-----------------------------------------------");
System.out.println("Specify entry payment amount:");
int payment = sc.nextInt();
if (payment <= 0)
{
System.ou... |
21945c66-e40a-41f6-810d-5549942c05fd | 9 | @Override
public void run(){
StaticVar.countProcess++;
//需要增加while循环检测connectionTimeOut并作相应处理,使其重新连接
while(this.connectTime<=maxConnectTime){
try {
this.httpUrl=(HttpURLConnection)new URL(downloadWorker.getHttpDownload().getSrcUrl()).openConnection();
break;
} catch (IOException e) {
// TODO A... |
beb03536-40c5-4484-a5bf-404cca3a71a1 | 4 | private void jButton21ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton21ActionPerformed
try {
if (jTable4.getSelectedRow() < 0) {
JOptionPane.showMessageDialog(this, "Please select server to delete", "Error", JOptionPane.ERROR_MESSAGE);
retur... |
1015c0ba-88de-46c2-abbe-7d4ba64e772f | 7 | private static void checkPanDigital(int[] indexes, HashMap<Integer, Integer> products) {
for (int split1 = 1; split1 < indexes.length - 1; split1++) {
for (int split2 = split1 + 1; split2 < indexes.length; split2++) {
StringBuilder sb1 = new StringBuilder();
for (int ... |
af1da002-1318-4458-b9b8-b17f1cd26d6e | 0 | public int getRed(){
return _red;
} |
3ade00d2-82da-4e84-83c9-2e05503c8029 | 0 | public Grammar getGrammar() {
return grammar;
} |
e2d14004-b2e1-4ef2-a779-a7aff11a0b04 | 2 | public void addComponentToPane(Container pane) {
// Set up the title image for reuse.
titleImage = null;
try {
titleImage = ImageIO.read(new File("src" + File.separator
+ "mentalpoker" + File.separator + "images"
+ File.separator + "title.png"));
} catch (IOException e) {
e.printStackTrace();
... |
f0b6b3ab-6ad8-4cad-93b8-9ec179812a10 | 3 | public int getValV(String nodeID, String attr){
increaseAccess();
Node n = nodeMap.get(nodeID);
if (n != null){
Object val = n.getAttr(attr);
if(val != null && val instanceof Integer){
return (Integer)val;
}
}
return Integer.MAX_VALUE;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.