method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
bf9cff3d-278b-4142-81b3-7c2ddebae49f | 9 | private void setUpPrettyFullBuffers(final int type, final int valueLength, boolean discontinuous)
throws PersistitException {
b1.init(type);
b2.init(type);
final boolean isData = type == Buffer.PAGE_TYPE_DATA;
int a, b;
// load page A with keys of increasing length
for (a = 10;; a++) {
setUpDeepKey(ex, 'a', a, isData ? 0 : a + 1000000);
setUpValue(isData, valueLength);
if (b1.putValue(ex.getKey(), vw) == -1) {
a -= 1;
break;
}
}
// set up the right edge key in page A
setUpDeepKey(ex, 'a', a, isData ? 0 : -1);
ex.getValue().clear();
b1.putValue(ex.getKey(), vw);
// set up the left edge key in page B
setUpDeepKey(ex, 'a', a, isData ? 0 : a + 1000000);
setUpValue(isData, valueLength);
b2.putValue(ex.getKey(), vw);
// load additional keys into page B
for (b = a;; b++) {
setUpDeepKey(ex, discontinuous && b > a ? 'b' : 'a', b, b + 1000000);
setUpValue(isData, valueLength);
if (b2.putValue(ex.getKey(), vw) == -1) {
break;
}
}
assertTrue("Verify failed", b1.verify(null, null) == null);
assertTrue("Verify failed", b2.verify(null, null) == null);
} |
bcc7f7b6-bedd-4982-883f-f3efd78ca045 | 1 | @Test
public void testContactIDs()
{
testSetUp();
cmInst.addNewContact("new contact", "new contact notes");
Set<Contact> thisSet = cmInst.getContacts(2, 8);
Set<Contact> thatSet = cmInst.getContacts("Syd");
// IDs 2 and 8 are two contacts
Assert.assertEquals(2, thisSet.size());
// two contacts contain "Syd"
Assert.assertEquals(2, thatSet.size());
for(Contact c: thatSet)
{
Assert.assertTrue(thisSet.contains(c));
}
} |
f3682511-c9ae-4053-b350-eb18ba663473 | 4 | public static boolean downloadPage(String path)throws HttpException,IOException{
InputStream input=null;
OutputStream output=null;
//õpost
PostMethod postMethod=new PostMethod(path);
//postIJ
NameValuePair[] postData=new NameValuePair[2];
postData[0]=new NameValuePair("name","lietu");
postData[1]=new NameValuePair("password","*****");
postMethod.addParameters(postData);
//ִУ״̬
int statusCode=httpClient.executeMethod(postMethod);
//״̬д(ֵֻΪ200״̬)
if(statusCode==HttpStatus.SC_OK){
input=postMethod.getResponseBodyAsStream();
//õļ
String filename=path.substring(path.lastIndexOf('/')+1);
//ļ
output=new FileOutputStream(filename);
//ļ
int tempByte=-1;
while((tempByte=input.read())>0){
output.write(tempByte);
}
//ر
if(input!=null){
input.close();
}
if(output!=null){
output.close();
}
return true;
}
return false;
} |
55277e72-bfd9-4647-8557-066b98f08130 | 2 | public static <T extends Number> T toNumber(Number number, Class<T> target) {
if (number == null) {
return null;
}
try {
return target.getConstructor(String.class).newInstance(number.toString());
} catch (Exception e) {
throw new RuntimeException(e);
}
} |
6521ec0b-cb61-4c46-b4f9-393ce46ca34f | 0 | public SummaryRanges() {
} |
7af5a4ba-f7ec-4a11-bb92-6589eecfe553 | 9 | private OutRec GetLowermostRec(OutRec outRec1, OutRec outRec2) {
// work out which polygon fragment has the correct hole state ...
if(outRec1.bottomPt == null)
outRec1.bottomPt = GetBottomPt(outRec1.pts);
if(outRec2.bottomPt == null)
outRec2.bottomPt = GetBottomPt(outRec2.pts);
OutPt bPt1 = outRec1.bottomPt;
OutPt bPt2 = outRec2.bottomPt;
if(bPt1.pt.y > bPt2.pt.y)
return outRec1;
else if(bPt1.pt.y < bPt2.pt.y)
return outRec2;
else if(bPt1.pt.x < bPt2.pt.x)
return outRec1;
else if(bPt1.pt.x > bPt2.pt.x)
return outRec2;
else if(bPt1.next == bPt1)
return outRec2;
else if(bPt2.next == bPt2)
return outRec1;
else if(FirstIsBottomPt(bPt1, bPt2))
return outRec1;
else
return outRec2;
} |
440213dc-1f5c-4646-b910-9296267a1145 | 8 | public int[][] init() {
int[][] binds = new int[17][9];
for (int[] row : binds)
Arrays.fill(row, Engine.INVALID);
for(int i = 0; i < hexList.size(); i++) {
Hex h = hexList.get(i);
int code = Engine.BLANK;
if(i == 0 || i == 32 || i == 53 )
code = Engine.RED;
else if( i == 4 || i == 25 || i == 57)
code = Engine.BLUE;
binds[h.getI()][h.getJ()] = code;
}
updateBoard(binds);
return binds;
} |
0fb29411-f4cf-4099-8442-5b92f633f201 | 1 | public static void main(String[] args) {
// Colection of CreditCards
ArrayList<CreditCard> cards = new ArrayList<CreditCard>();
// Our CreditCard objects
CreditCard card1 = new CreditCard("Madalin Ignisca", 2500);
CreditCard card2 = new CreditCard("John Doe", 1400);
CreditCard card3 = new CreditCard("Jane Doe", 750);
// CreditCards purchases
card1.makePurchase(1000);
card1.makePurchase(1500);
card2.makePurchase(200);
card2.makePurchase(400);
card2.makePurchase(150);
card3.makePurchase(950);
// CreditCard payments
card1.makePayment(50);
card2.makePayment(25);
card3.makePayment(75);
// Add CreditCards to cards ArrayList
cards.add(card1);
cards.add(card2);
cards.add(card3);
// Printing out CreditCard information
for (CreditCard card : cards) {
System.out.println("The cardholder is: " + card.getCardHolder());
System.out.println("Total credit limit: " + card.getCreditLimit());
System.out.println("Total balance: " + card.getBalance());
System.out.println("Total reward points: "
+ card.calculateRewardPoints());
System.out.println("--------------------------------------------");
}
/*
* System.out.println(card.getCardHolder());
* System.out.println(card.getCreditLimit()); card.makePurchase(1500);
* card.makePayment(200); card.makePurchase(1000);
* System.out.println(card.getBalance());
* System.out.println(card.calculateRewardPoints());
* card.makePurchase(300); System.out.println(card.getBalance());
* System.out.println(card.calculateRewardPoints());
*/
} |
40f3afc2-a6e1-4fea-821c-06a04b239511 | 3 | public static String getVariableThatBelongsInUsefulVariableSet(
Grammar grammar, Set set) {
String[] variables = grammar.getVariables();
for (int k = 0; k < variables.length; k++) {
if (belongsInUsefulVariableSet(variables[k], grammar, set)
&& !set.contains(variables[k]))
return variables[k];
}
return null;
} |
586d23f3-fe9d-4f1f-a2ad-1a020ae01c12 | 9 | void run(){
Scanner sc = new Scanner(System.in);
h = sc.nextInt(); w = sc.nextInt(); N = sc.nextInt();
char[][] m = new char[h][], t = new char[h][w];
for(int i=0;i<h;i++)m[i]=sc.next().toCharArray();
boolean ok = false;
for(int i=0;i<h&&!ok;i++)for(int j=0;j<w-1&&!ok;j++){
if(m[i][j]!=m[i][j+1]){
for(int y=0;y<h;y++)for(int x=0;x<w;x++)t[y][x]=m[y][x];
char x = t[i][j];
t[i][j] = t[i][j+1]; t[i][j+1] = x;
ok = f(t);
}
}
System.out.println(ok?"YES":"NO");
} |
c6a40707-4de3-4b15-b6c1-b7763fac308b | 7 | private static String guessNested(String mvcName) {
StringBuffer result = new StringBuffer(mvcName.length());
char[] source = mvcName.toCharArray();
for (int i =0; i < source.length; i++) {
char ch = source[i];
if (Character.isUpperCase(ch)) {
// customerName -> customer.name
result.append("." + Character.toLowerCase(ch));
} else if (Character.isDigit(ch)) {
// customers12Name -> customers[12].name
result.append('[');
result.append(ch);
i++;
boolean found = false;
// adding other digits until letter is found...
for ( ; !found && i < source.length; i++) {
ch = source[i];
if (Character.isDigit(ch)) {
result.append(ch);
} else {
// closing the digit part...
result.append(']'); // closing the digit part
result.append('.'); // adding the separator
result.append(Character.toLowerCase(ch)); // adding the letter
found = true; // exiting to outer loop...
i--; // moving back for the outer loop...
}
}
// adding ']' if the end was reached..
if (i==source.length) {
result.append(']');
}
} else {
result.append(ch);
}
}
return result.toString();
} |
7d8d2ae7-9fd8-41e9-b5f0-c64e60d10a97 | 2 | public Object getVariable(String name) {
if(variables.containsKey(name)) {
return variables.get(name);
}
else if(parent!=null) {
return parent.getVariable(name);
}
else
throw new RuntimeException("Variable <" + name + "> undefined");
} |
43990c2f-1ad1-4dc2-b0ce-9758bd89a0f2 | 3 | public void display() {
// Instantiate an Entry
BufHTEntry cur;
System.out.println("HASH Table contents :FrameNo[PageNo]");
// Interate through the Page Table array
for (int i = 0; i < HTSIZE; i++) {
System.out.println("Array Index: " + i);
if (ht[i] != null) {
// Iterate through the linked list in the current bucket
for (cur = ht[i]; cur != null; cur = cur.next)
System.out.println("\t" + cur.frameNo + "[" + cur.pageNo.pid + "]");
} else {
System.out.println("\t EMPTY");
}
}
System.out.println("");
} // end display() |
e499bd2f-4ba8-434b-90ab-0bef9f61399b | 1 | public void add(final LocalExpr use, final Instruction inst) {
final Node def = use.def();
if (def != null) {
map.put(inst, def);
}
} |
eb232d0d-4bad-40ff-8f5d-2eced1c774f7 | 5 | public void merge (int[] array, int a, int b, int x, int y, int w) {
int i = a, j = x;
int temp = 0;
while (i<=b && j <= y) {
if (array[i] < array[j]) {
temp = array[i];
array[i] = array[w];
array[w] = temp;
i++;
} else {
temp = array[j];
array[j] = array[w];
array[w] = temp;
j++;
}
w++;
while (i<=b) {
temp = array[i];
array[i] = array[w];
array[w] = temp;
i++;
w++;
}
while (j<=y) {
temp = array[j];
array[j] = array[w];
array[w] = temp;
j++;
w++;
}
}
} |
c75c6aff-b090-4803-a8a5-0455e6b586d5 | 9 | private int evalFunctions(List<Token> formula, int offset, int length) {
for (int i = offset + length - 2; i >= offset; i--) {
for (Function function : Tokens.function(formula.get(i))) {
if (i == offset ||
(!(formula.get(i - 1) instanceof NumberToken) &&
!(formula.get(i - 1) instanceof ArgumentToken))) {
Token arguments = formula.get(i + 1);
BigDecimal[] values = null;
for (ArgumentToken argument : Tokens.argument(arguments)) {
values = argument.getArguments();
}
for (NumberToken numberToken : Tokens.number(arguments)) {
values = new BigDecimal[]{numberToken.getNumber()};
}
if (values == null) {
throw new ParseException("Missing arguments for " + function + ", found: " + arguments);
}
if (!function.hasArity(values.length)) {
throw new ParseException("Wrong number of arguments for " + function + ", found: " +
values.length);
}
formula.remove(i + 1);
formula.set(i, new NumberToken(function.calculate(values)));
length--;
}
}
}
return length;
} |
fb429f50-d9cc-4944-a8f2-2708c667368f | 0 | public DiagnosticoFacade() {
super(Diagnostico.class);
} |
85a7305d-54c7-429f-862e-91f17019de0e | 6 | private void processSuperClazzes(Class<?> clazz) {
List<Class<?>> superClazzes;
superClazzes = new ArrayList<Class<?>>();
while (clazz != null && clazz != this.getUpToClass()) {
superClazzes.add(clazz);
clazz = clazz.getSuperclass();
}
for (int i = superClazzes.size() - 1; i >= 0; i--) {
clazz = superClazzes.get(i);
this.appendFieldsIn(clazz);
}
} |
f0f38843-2c86-471d-a664-2e6f3b355af6 | 5 | public static void main(String[] args) throws UnknownHostException,
IOException {
int localVersion = getLocalVersion();
if (localVersion == -1
|| !InetAddress.getByName(SERVER).isReachable(5000)
|| (args.length > 1 && args[1].equals("ultraulf"))) {
System.out.println("Starting local version.");
startLocal();
return;
}
int remoteVersion = getRemoteVersion();
int downloadedVersion = getDownloadedJarVersion();
if (remoteVersion > downloadedVersion) {
System.out.println("Starting remote version.");
downloadAndStartRemoteJar();
} else {
System.out.println("Starting cached version.");
startJar(DOWNLOADED_FILE.getAbsolutePath());
}
} |
8b402d2c-ff1e-4807-908c-6c400fb1ceaf | 2 | protected void saveFile() {
List<Variable> variableList = obfuscator.getProjectVariableList();
if (variableList != null) {
String fileName = saveFileDialog();
if (fileName != null) {
int fileSize = McbcFileUtils.saveVariableList(fileName, variableList);
MessageDialog.displayMessageDialog(this, "INFORMATION_DIALOG", "FILE_SAVED", fileName, fileSize);
}
} else {
MessageDialog.displayMessageDialog(this, "INFORMATION_DIALOG", "NO_VAR_TO_SAVE");
}
} |
a9d8f046-c350-43bf-9f12-13525f0dbd63 | 1 | @Test
public void validateBudgetBreakdownThrowExceptionIfNull() {
Budget budget = createAnnualBudget("Annual Budget", new BigDecimal("2000"));
try {
calculateBudgetBreakdown.calculateBreakdown(budget, null);
fail("BudgetBreakdown Object Is Null.");
} catch(Exception e) {
assertEquals("BudgetBreakdown is null.", e.getMessage());
}
} |
2f1bc90f-e5c5-4417-b82b-d660c7a09a65 | 3 | private static Method getMethod (Class<?> clazz, String method)
{
for (Method m : clazz.getMethods())
{
if (m.getName().equals(method))
{
return m;
}
}
return null;
} |
791685aa-b6bb-4959-a935-bc47880eb650 | 8 | public static boolean checkInterrupts() {
if (NMIEnable && intVBlank) {
if (!Settings.isTrue(Settings.CPU_ALT_DEBUG)) {
Log.debug("Running vblank handler: " + Integer.toHexString(Core.mem.get(Size.SHORT, 0, 0xFFEA)));
} else {
Log.instruction("*** NMI");
}
stackPush(Size.BYTE, pbr.getValue());
stackPush(Size.SHORT, pc.getValue());
stackPush(Size.BYTE, status.getValue());
status.setDecimalMode(false); // See pg 194 in the cpu documentation
pbr.setValue(0);
if (!CPU.emulationMode)
pc.setValue(Core.mem.read(Size.SHORT, 0, 0xFFEA));
else
pc.setValue(Core.mem.read(Size.SHORT, 0, 0xFFFA));
intVBlank = false;
return true;
} else if (intIRQ) {
intIRQ = false;
if (!status.isIrqDisable()) {
if (!Settings.isTrue(Settings.CPU_ALT_DEBUG)) {
Log.debug("Running irq handler: " + Integer.toHexString(Core.mem.get(Size.SHORT, 0, 0xFFEE)));
} else {
Log.instruction("*** IRQ");
}
irqFlag = true;
stackPush(Size.BYTE, pbr.getValue());
stackPush(Size.SHORT, pc.getValue());
stackPush(Size.BYTE, status.getValue());
status.setDecimalMode(false); // See pg 194 in the cpu documentation
pbr.setValue(0);
if (!CPU.emulationMode)
pc.setValue(Core.mem.read(Size.SHORT, 0, 0xFFEE));
else
pc.setValue(Core.mem.read(Size.SHORT, 0, 0xFFFE));
return true;
}
}
return false;
} |
9a4c1a30-6061-477f-a7f3-3eeeec046287 | 0 | public List findByPassword(Object password) {
return findByProperty(PASSWORD, password);
} |
7b269add-5209-424e-a8e9-38abe508f325 | 2 | public Metrics(final Plugin plugin) throws IOException {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
}
this.plugin = plugin;
// load the config
configurationFile = new File(CONFIG_FILE);
configuration = YamlConfiguration.loadConfiguration(configurationFile);
// add some defaults
configuration.addDefault("opt-out", false);
configuration.addDefault("guid", UUID.randomUUID().toString());
// Do we need to create the file?
if (configuration.get("guid", null) == null) {
configuration.options().header("http://mcstats.org").copyDefaults(true);
configuration.save(configurationFile);
}
// Load the guid then
guid = configuration.getString("guid");
} |
0a716653-53ff-4869-9328-32c7649ece3c | 4 | private void showStorage (StringBuffer buf, boolean external)
throws IOException
{
int temp = rio.getFreeMemory (external);
MemoryStatus mem = rio.getMemoryStatus (external);
// basic memory statistics
buf.append ("<em>");
buf.append (external ? "SmartMedia" : "Built-in Memory");
buf.append ("</em>");
buf.append (" ");
buf.append (temp / (1024 * 1024));
buf.append (".");
buf.append ((10 * (temp % (1024 * 1024))) / (1024 * 1024));
buf.append (" MB free<br>\n");
// XXX "NN MBytes" ... forget the block count
temp = mem.getBlockCount ();
if (temp != 0)
temp = ((temp - mem.getNumUnusedBlocks ()) * 100) / temp;
else
temp = 1000;
// blocksize always 16K ?
buf.append (mem.getNumUnusedBlocks ());
buf.append ("/");
buf.append (mem.getBlockCount ());
buf.append (" blocks available, ");
buf.append (temp);
buf.append ("% full<br>");
for (int i = 0; i < folders.length; i++) {
if (folders [i].isExternal () != external)
continue;
buf.append ("Folder <em>");
buf.append (folders [i].getName1 ());
buf.append ("</em>");
buf.append (" ... has ");
buf.append (folders [i].getSongCount ());
buf.append (" songs.");
buf.append ("<br>\n");
}
buf.append ("<br>\n");
} |
f25183c2-d4c7-419e-9eba-10b89976ed0d | 0 | @Override
public void setBoard (Board board){
field=board;
} |
da086da6-8f3d-4c81-9009-a5d67f380d59 | 0 | */
private static int randomDirection() {
return (int) (Math.random() * Direction.values().length);
} |
a37826b2-2eb8-4c59-84f1-4137c288a99c | 7 | public double target(double[] x, double[][] X, int rowpos, double[] Y){
double y = Y[rowpos], result=0;
for(int i=0; i < X.length; i++){
if((i != rowpos) && (X[i] != null)){
double var = (y==Y[i]) ? 0.0 : Math.sqrt((double)m_Dimension - 1);
double f=0;
for(int j=0; j < m_Dimension; j++)
if(Utils.gr(m_Variance[rowpos][j], 0.0)){
f += x[j]*(X[rowpos][j]-X[i][j]) * (X[rowpos][j]-X[i][j]);
//System.out.println("i:"+i+" j: "+j+" row: "+rowpos);
}
f = Math.sqrt(f);
//System.out.println("???distance between "+rowpos+" and "+i+": "+f+"|y:"+y+" vs "+Y[i]);
if(Double.isInfinite(f))
System.exit(1);
result += 0.5 * (f - var) * (f - var);
}
}
//System.out.println("???target: "+result);
return result;
} |
bf1e17fd-be0f-4fe4-bb1b-2b48edb56be9 | 2 | public static void loadAllAchievements() {
String statement = new String("SELECT * FROM " + DBTable + " WHERE type = ?");
PreparedStatement stmt;
try {
stmt = DBConnection.con.prepareStatement(statement);
stmt.setInt(1, QUIZ_TAKEN_TYPE);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
QuizTakenAchievement achievement = new QuizTakenAchievement(rs.getInt("aid"), rs.getString("name"), rs.getString("url"),
rs.getString("description"), rs.getInt("threshold"));
allAchievements.add(achievement);
}
rs.close();
} catch (SQLException e) {
e.printStackTrace();
}
} |
4635ac64-fcec-4669-b4e4-d8bc11d36aa4 | 2 | private void updateTitle(){
File file = getProgram().getFile();
String title;
if (file != null){
title = file.getName();
} else {
title = "Unsaved Program";
}
if (getProgram().isDirty()){
title+=" *";
}
setTitle("LOGO - "+title);
} |
6084d3ab-61ea-41c5-a80a-7b274f5cca9e | 2 | public void setAppliedVoltage(double voltage){
this.appliedVoltage = new Complex(voltage, 0.0D);
this.appliedVoltageError = new Complex(0.0D, 0.0D);
this.appliedVoltageSet = true;
if(this.referenceSet && this.frequenciesSet)this.calculateExperimentalImpedances();
} |
5d1e2061-993d-48f8-a212-86fdd8a02e4e | 4 | public static String substringBeforeLast(String sourceStr, String expr) {
if (isEmpty(sourceStr) || expr == null) {
return sourceStr;
}
if (expr.length() == 0) {
return sourceStr;
}
int pos = sourceStr.lastIndexOf(expr);
if (pos == -1) {
return sourceStr;
}
return sourceStr.substring(0, pos);
} |
a25a9510-1c09-4caa-a404-1cafa6d31a5b | 3 | public void actionPerformed(ActionEvent e) {
Grammar grammar = environment.getGrammar();
if (grammar == null)
return;
if (grammar.getProductions().length == 0) {
JOptionPane.showMessageDialog(Universe
.frameForEnvironment(environment),
"The grammar should exist.");
return;
}
// Create the initial automaton.
PushdownAutomaton pda = new PushdownAutomaton();
CFGToPDALRConverter convert = new CFGToPDALRConverter();
convert.createStatesForConversion(grammar, pda);
// Create the map of productions to transitions.
HashMap ptot = new HashMap();
Production[] prods = grammar.getProductions();
for (int i = 0; i < prods.length; i++)
ptot.put(prods[i], convert.getTransitionForProduction(prods[i]));
// Add the view to the environment.
final ConvertPane cp = new ConvertPane(grammar, pda, ptot, environment);
environment.add(cp, "Convert to PDA (LR)", new CriticalTag() {
});
// Do the layout of the states.
AutomatonGraph graph = new AutomatonGraph(pda);
LayoutAlgorithm layout = new GEMLayoutAlgorithm();
layout.layout(graph, null);
graph.moveAutomatonStates();
environment.setActive(cp);
environment.validate();
cp.getEditorPane().getAutomatonPane().fitToBounds(20);
} |
e4afe280-5b42-4bf3-a9bf-396b72db60fd | 2 | public Game build() {
if (rolls_list.isEmpty()) {
throw new AnyRollToPlay();
}
if (player_list.size() < 2) {
throw new NotEnoughtPlayersToPlay();
}
return new Game(this);
} |
d51aa091-eda0-4af2-bf2b-3bda2b37ae3d | 7 | public static boolean nodeEquals(Node<Integer, String> a,
Node<Integer, String> b) {
Deque<Tuple<Node<Integer, String>, Node<Integer, String>>> nodesToVisit
= new ArrayDeque<Tuple<Node<Integer, String>, Node<Integer, String>>>();
nodesToVisit.addLast(new Tuple<Node<Integer, String>, Node<Integer, String>>(a,b));
while(!nodesToVisit.isEmpty()) {
Tuple<Node<Integer, String>, Node<Integer, String>> visit = nodesToVisit.removeFirst();
a = visit.getX();
b = visit.getY();
if(a == b) {
continue;
}
if (a == null || b == null) {
return false;
}
if (a.isBlack() != b.isBlack()) {
return false;
}
if (!(a.getKey().equals(b.getKey()))) {
return false;
}
if (!(a.getValue().equals(b.getValue()))) {
return false;
}
nodesToVisit.add(new Tuple<Node<Integer,String>, Node<Integer,String>>(a.getLeft(), b.getLeft()));
nodesToVisit.add(new Tuple<Node<Integer,String>, Node<Integer,String>>(a.getRight(), b.getRight()));
}
return true;
} |
489da7b4-2a69-41d3-95c0-3a3ef540ac93 | 2 | public static GUIAbsTemplate getInstance(){
switch(showGUITypeAsk()){
case 0:
return GUIAbsTemplate.getChainInstance(GUIImplCommandLine.getInstance());
case 1:
return GUIAbsTemplate.getChainInstance(GUIImplGPopupWindow.getInstance());
default:
return null;
}
} |
0339a99e-5a44-4617-b4f6-65755d64b710 | 4 | private String[] getNameFromCookie(Cookie[] cookies){
String name = "";
if(cookies != null){
for (Cookie ck : cookies) {
if ("CILOGON-USER_NAME".equals(ck.getName()) && !ck.getValue().equals("")) {
name = (String)ck.getValue();
}
}
return name.split(" ");
}
return null;
} |
6b32cef7-1438-4476-a06d-7bac9dec8501 | 7 | boolean validateMove(movePair movepr, Pair pr) {
// This is also from dumbPlayer, and seems like something we won't have to use
Point src = movepr.src;
Point target = movepr.target;
boolean rightposition = false;
if (Math.abs(target.x-src.x)==Math.abs(pr.p) && Math.abs(target.y-src.y)==Math.abs(pr.q)) {
rightposition = true;
}
if (Math.abs(target.x-src.x)==Math.abs(pr.q) && Math.abs(target.y-src.y)==Math.abs(pr.p)) {
rightposition = true;
}
if (rightposition && src.value == target.value && src.value >0) {
return true;
}
else {
return false;
}
} |
f7fa2623-d023-4929-a317-846faf47c065 | 1 | public static void playSound(String path){
try {
Clip clip = AudioSystem.getClip();
InputStream is = GameManager.class.getResourceAsStream(path);
BufferedInputStream bIs = new BufferedInputStream(is);
AudioInputStream aIs = AudioSystem.getAudioInputStream(bIs);
clip.open(aIs);
clip.start();
}
catch (Exception ex){
ex.printStackTrace();
}
} |
a029edda-4736-4e23-b9ac-5141b5065e77 | 2 | private <T> T[] ensureIndex( T[] array, int index, T ... emptyArray )
{
if (array == null)
{
array = Arrays.copyOf( emptyArray, index + 1 );
}
else if (index >= array.length)
{
array = Arrays.copyOf( array, index + 1 );
}
return array;
} |
fc221b16-0370-463c-86ab-9897df895aa7 | 6 | public boolean deplacementPossible(Point2D point) {
Path2D p = _bateau.boundingsPosition(point);
boolean dansEau = false;
boolean dansShape = false;
for(Forme forme:_formes) {
if(forme.getPathOriginal().intersects(p.getBounds2D())) {
if (forme.getTypeForme()==TypeShape.NATURAL) {
dansEau = true;
} else if(forme==_bateau) {
return true;
} else {
if(forme.getTypeForme()!=TypeShape.HIGHWAY) {
dansShape = true;
} else {
dansEau = true;
}
}
}
}
return dansEau && !dansShape;
} |
b668d7ce-113c-4e96-b0ed-615b5b432fcb | 7 | private RdpPacket_Localised receiveMessage(int[] type, Options option,
Rdp rdpLayer) throws IOException, RdesktopException,
OrderException, CryptoException {
// logger.debug("ISO.receiveMessage");
RdpPacket_Localised s = null;
int length, version;
next_packet: while (true) {
// logger.debug("next_packet");
GWT.log("tcp receive called");
s = tcp_recv(null, 4, option);
GWT.log("tcp receive end");
if (s == null)
return null;
GWT.log("s is not null");
version = s.get8();
if (version == 3) {
GWT.log("version is 3");
s.incrementPosition(1); // pad
length = s.getBigEndian16();
} else {
GWT.log("version is not 3");
length = s.get8();
GWT.log("length:" + Integer.toHexString(length));
if ((length & 0x80) != 0) {
length &= ~0x80;
GWT.log("length:" + Integer.toHexString(length));
length = (length << 8) + s.get8();
GWT.log("length:" + Integer.toHexString(length));
}
}
GWT.log("out of version thing, length:" + length);
s = tcp_recv(s, length - 4, option);
if (s == null)
return null;
if ((version & 3) == 0) {
// logger.info("Processing rdp5 packet");
rdpLayer.rdp5_process(s, (version & 0x80) != 0, option);
continue next_packet;
} else
break;
}
s.get8();
type[0] = s.get8();
if (type[0] == DATA_TRANSFER) {
// logger.debug("Data Transfer Packet");
s.incrementPosition(1); // eot
return s;
}
s.incrementPosition(5); // dst_ref, src_ref, class
return s;
} |
0804f469-81c3-45cb-8c63-f8f95499bdef | 1 | public static float[] normalize(float[] arr){
float sum = sum(arr);
for (int i = 0 ; i < arr.length; i++){
arr[i] = arr[i] / sum;
}
return arr;
} |
6734d4c2-f7be-4e1b-b84c-ef60ddb1bdec | 9 | @Override
public void caseADeclSeDefinicaoComando(ADeclSeDefinicaoComando node)
{
inADeclSeDefinicaoComando(node);
if(node.getSe() != null)
{
node.getSe().apply(this);
}
if(node.getLPar() != null)
{
node.getLPar().apply(this);
}
if(node.getExpLogica() != null)
{
node.getExpLogica().apply(this);
}
if(node.getRPar() != null)
{
node.getRPar().apply(this);
}
if(node.getEntao() != null)
{
node.getEntao().apply(this);
}
if(node.getComando() != null)
{
node.getComando().apply(this);
}
if(node.getOpcionalSenaoSe() != null)
{
node.getOpcionalSenaoSe().apply(this);
}
if(node.getFimSe() != null)
{
node.getFimSe().apply(this);
}
if(node.getPontoVirgula() != null)
{
node.getPontoVirgula().apply(this);
}
outADeclSeDefinicaoComando(node);
} |
683cfd25-94e8-4425-8b90-966e82eacedd | 9 | private boolean binarySearch(int[] A, int start, int end, int target) {
if (start > end) {
return false;
}
int middle = start + (end - start) / 2;
if (A[middle] == target) {
return true;
}
// Find the correct sequence.
if (A[start] < A[middle] || A[start] == A[middle] && check(A, start, middle)) {
if (A[start] <= target && target < A[middle]) {
return binarySearch(A, start, middle - 1, target);
} else {
return binarySearch(A, middle + 1, end, target);
}
} else {
if (A[middle] < target && target <= A[end]) {
return binarySearch(A, middle + 1, end, target);
} else {
return binarySearch(A, start, middle - 1, target);
}
}
} |
93975734-edcc-468f-9eb6-2f3b93018b00 | 4 | private boolean checkLineForm(String line, int parameterNumber)
{
switch(parameterNumber)
{
case 0:
if(line.indexOf(FIRST_PARAMETER) == 0)
return true;
else
return false;
case 1:
if(line.indexOf(SECOND_PARAMETER) == 0)
return true;
else
return false;
default:
return false;
}
} |
c9645e16-7e05-4c40-bf33-6507491958af | 8 | public static long getSize(Object object) {
if (object == null) {
return 0;
} else if (object instanceof SizeObject) {
return ((SizeObject) object).getSize();
} else if (object instanceof Boolean) {
return 1;
} else if (object instanceof String) {
return object.toString().length() * 256;
} else if (object instanceof Number) {
return object.toString().length();
} else if (object instanceof Iterable) {
long size = 0;
for (Object entry : (Iterable<?>) object) {
size += getSize(entry);
}
return size;
} else {
throw new IllegalArgumentException("Type " + object.getClass().getName() + " isn't a SizeObject, string, boolean or number");
}
} |
8adfce99-0794-4ce2-9f32-55fde35a053d | 4 | private DragSource createTableDragSource(final Table table) {
DragSource dragSource = new DragSource(table, DND.DROP_MOVE | DND.DROP_COPY);
dragSource.setTransfer(new Transfer[] { FileTransfer.getInstance() });
dragSource.addDragListener(new DragSourceListener() {
TableItem[] dndSelection = null;
String[] sourceNames = null;
public void dragStart(DragSourceEvent event){
dndSelection = table.getSelection();
sourceNames = null;
event.doit = dndSelection.length > 0;
isDragging = true;
}
public void dragFinished(DragSourceEvent event){
dragSourceHandleDragFinished(event, sourceNames);
dndSelection = null;
sourceNames = null;
isDragging = false;
handleDeferredRefresh();
}
public void dragSetData(DragSourceEvent event){
if (dndSelection == null || dndSelection.length == 0) return;
if (! FileTransfer.getInstance().isSupportedType(event.dataType)) return;
sourceNames = new String[dndSelection.length];
for (int i = 0; i < dndSelection.length; i++) {
File file = (File) dndSelection[i].getData(TABLEITEMDATA_FILE);
sourceNames[i] = file.getAbsolutePath();
}
event.data = sourceNames;
}
});
return dragSource;
} |
f7d0baa3-9d1e-4a93-82d4-5c93e8b3dba5 | 6 | static public short getCRC(byte[] buf, int len)
{
short i;
short crc = 0x7fff;
boolean isNeg = true;
for(int j = 0; j < len; j++) {
crc ^= buf[j] & 0xff;
for (i = 0; i < 8; i++) {
if ((crc & 1) == 0) {
crc >>= 1;
if (isNeg) {
isNeg = false;
crc |= 0x4000;
}
} else {
crc >>= 1;
if (isNeg) {
crc ^= 0x4408;
} else {
crc ^= 0x0408;
isNeg = true;
}
}
}
}
return isNeg ? (short) (crc | (short) 0x8000) : crc;
} |
9e36311e-29a5-407f-9492-708a61aafcf8 | 6 | public ArrayList<Node> extractComponent(ArrayList<Node> in, int n){
Set<Integer> S = new HashSet<>();
ArrayList<Integer> D = new ArrayList<>();
int d;
D.add(n);
Node N;
int p;
while(!D.isEmpty())
{
d = D.remove(0);
S.add(d);
N = in.get(d);
for(int i=0;i<N.getDegree();i++)
{
p = N.getNeighbour(i).id;
if(!S.contains(p))
{
S.add(p);
if(!D.contains(p))
{
D.add(p);
}
}
}
}
Iterator it = S.iterator();
ArrayList<Node> res = new ArrayList<Node>();
while(it.hasNext())
{
d = (Integer)it.next();
res.add(in.get(d));
}
in.clear();
for(int i=0;i<res.size();i++)
{
res.get(i).id=i;
}
return res;
} |
3da9e6a4-8b76-4746-9aff-efbf95fe8f54 | 1 | public FunctionalList rest() {
FunctionalArrayList output = new FunctionalArrayList();
for (int i = 0; i < size(); i++) {
Object currentElementValue = array[i];
output.add(currentElementValue);
}
output.remove(0);
return output;
} |
5a65bc2b-4b4a-4345-8848-ee32d42d4d53 | 9 | @Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
final Parameter that = (Parameter) obj;
if (key == null) {
if (that.key != null)
return false;
} else if (!key.equals(that.key))
return false;
if (value == null) {
if (that.value != null)
return false;
} else if (!value.equals(that.value))
return false;
return true;
} |
37b59cc2-453e-4431-a3cf-3b15dcd80662 | 5 | protected void take(Player winner, Player loser, int amount,boolean ron)
{
if (amount % 100 != 0)
amount = amount + 100 - (amount % 100);
String claimer=winner.name;
if(!winner.in || !ron){
claimer=Console.POT;
}
if(winner.score < 0){
if(amount+winner.score <=0){
claimer=Console.POT;
}
else{
int a=-winner.score;
winner.give(loser.take(a, Console.POT,namedate),namedate);
amount=amount-a;
}
}
winner.give(loser.take(amount, claimer,namedate),namedate);
} |
fd819831-4413-4d8f-9216-0f79b21d925d | 5 | public static List<List<Integer>> levelOrder(TreeNode root) {
List<List<Integer>> res = new ArrayList<List<Integer>>();
List<TreeNode> stack = new ArrayList<TreeNode>();
int start = 0;
int end = 0;
if (null != root) {stack.add(root);end = 1;}
while (end > start) {
List<Integer> level = new ArrayList<Integer>();
for (int i = start; i < end; i++) {
TreeNode node = stack.get(i);
level.add(node.val);
if (null != node.left) {
stack.add(node.left);
}
if (null != node.right) {
stack.add(node.right);
}
}
res.add(level);
start = end;
end = stack.size();
}
return res;
} |
66e9488a-4dcc-4812-a0a9-3a353d2b10d1 | 4 | public HashMap<Integer, Integer[]> countOfPassengerOnEveryStation(Train train) {
log.debug("Start countOfPassengerOnEveryStation select");
List stationFrom = em.createQuery("select station.id, 0, count(ticket.id), schedule.seqNumber " +
"from Train train " +
"left join train.ticketsById ticket " +
"inner join ticket.stationByStationFrom station " +
"inner join train.routeByIdRoute route " +
"inner join route.schedulesById schedule " +
"inner join schedule.wayByIdWay way " +
"inner join way.stationByIdStation1 stationFrom " +
"where train.name = :name " +
"and stationFrom.id = station.id " +
" group by station.id")
.setParameter("name", train.getName())
.getResultList();
List stationTo = em.createQuery("select station.id, 0, count(ticket.id), schedule.seqNumber " +
"from Train train " +
"left join train.ticketsById ticket " +
"inner join ticket.stationByStationTo station " +
"inner join train.routeByIdRoute route " +
"inner join route.schedulesById schedule " +
"inner join schedule.wayByIdWay way " +
"inner join way.stationByIdStation2 stationTo " +
"where train.name = :name " +
"and stationTo.id = station.id " +
" group by station.id")
.setParameter("name", train.getName())
.getResultList();
HashMap<Integer, Integer[]> result = new HashMap<Integer, Integer[]>();
for (Object[] obj : (List<Object[]>) stationFrom) {
if (result.containsKey(obj[0])) {
Integer[] a = result.get(obj[0]);
a[0] += ((Long) obj[2]).intValue();
result.put((Integer) obj[0], a);
} else {
result.put((Integer) obj[0], new Integer[]{((Long) obj[2]).intValue(), ((Long) obj[1]).intValue(), ((Integer) obj[3])-1});
}
}
for (Object[] obj : (List<Object[]>) stationTo) {
if (result.containsKey(obj[0])) {
Integer[] a = result.get(obj[0]);
a[1] += ((Long) obj[2]).intValue();
result.put((Integer) obj[0], a);
} else {
result.put((Integer) obj[0], new Integer[]{((Long) obj[1]).intValue(), ((Long) obj[2]).intValue(), (Integer) obj[3]});
}
}
return result;
} |
44f293b2-9727-4d55-bc94-14816a64d6f2 | 3 | private void loadDomain(String domaine_selection) {
try {
ObjectInputStream input_domain = new ObjectInputStream(new FileInputStream(domaine_selection+FILE_EXTENSION));
domaine = (Domaine) input_domain.readObject();
input_domain.close();
} catch (FileNotFoundException e) {
javax.swing.JOptionPane.showMessageDialog(MainWindow.this.frmDocumentmanager,"Impossible de charger le domaine : " + e.getMessage());
e.printStackTrace();
} catch (IOException e) {
javax.swing.JOptionPane.showMessageDialog(MainWindow.this.frmDocumentmanager,"Impossible de lire le domaine : " + e.getMessage());
e.printStackTrace();
} catch (ClassNotFoundException e) {
javax.swing.JOptionPane.showMessageDialog(MainWindow.this.frmDocumentmanager,"Données incompatibles : " + e.getMessage());
e.printStackTrace();
}
updateFrameContent();
} |
8f1b2ea8-89c2-425d-813d-4079dafca872 | 1 | public int minX() {
int m = coords[0][0];
for (int i = 0; i < 4; i++) {
m = Math.min(m, coords[i][0]);
}
return m;
} |
5482953a-278b-459c-9a31-4033ea86acd4 | 0 | @Override
public void getUsernameFromUI(String username) {
this.username = username;
ClientFinder.init(username, interfaceName);
} |
246e1d47-349c-4f55-beef-bd29fdec9a81 | 9 | private boolean jj_scan_token(int kind) {
if (jj_scanpos == jj_lastpos) {
jj_la--;
if (jj_scanpos.next == null) {
jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
} else {
jj_lastpos = jj_scanpos = jj_scanpos.next;
}
} else {
jj_scanpos = jj_scanpos.next;
}
if (jj_rescan) {
int i = 0; Token tok = token;
while (tok != null && tok != jj_scanpos) { i++; tok = tok.next; }
if (tok != null) jj_add_error_token(kind, i);
}
if (jj_scanpos.kind != kind) return true;
if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
return false;
} |
2c8fc0ca-bfca-45de-bbde-2fd8723e090b | 5 | public void print() {
// prints the BigInt as a integer
int len = this.length();
if(len == 0) {
System.out.println("0");
return;
}
for(int i = len - 1; i >= 0; i--) {
String zfill = "";
for(int j = power_ - 1; j > 0; j--) {
if(getDigit(i).value() < (long)Math.pow(10, j)) {
if(i < len - 1)
zfill += "0";
}
else break;
}
System.out.print(zfill + getDigit(i).value());
}
System.out.print("\n");
} |
1a20eb52-32c5-4ac7-afea-f71f0d681400 | 5 | private static HashMap<Integer, HashMap<Color, Integer>> createSilverMap()
{
HashMap<Integer, HashMap<Color, Integer>> map = new HashMap<Integer, HashMap<Color, Integer>>();
map.put(1, new HashMap<Color, Integer>());
map.get(1).put(Faction.YELLOW, 1);
map.get(1).put(Faction.RED, 2);
map.get(1).put(Faction.BLUE, 3);
map.get(1).put(Faction.GREEN, 4);
map.get(1).put(Faction.BLACK, 5);
map.get(1).put(Faction.WHITE, 6);
for(int i = 2; i <= 30; i++)
{
map.put(i, new HashMap<Color, Integer>());
if(i % 6 == 1)
{
for(Color f : Faction.allFactions())
{
map.get(i).put(f, map.get(i-1).get(f));
}
}
else
{
for(Color f : Faction.allFactions())
{
if(map.get(i-1).get(f) == 6)
{
map.get(i).put(f, 1);
}
else
{
map.get(i).put(f, map.get(i-1).get(f)+1);
}
}
}
}
return map;
} |
bd70ef33-1b99-46b0-84b6-b9e627b080c8 | 8 | private boolean r_prelude() {
int among_var;
int v_1;
// repeat, line 36
replab0: while(true)
{
v_1 = cursor;
lab1: do {
// (, line 36
// [, line 37
bra = cursor;
// substring, line 37
among_var = find_among(a_0, 3);
if (among_var == 0)
{
break lab1;
}
// ], line 37
ket = cursor;
switch(among_var) {
case 0:
break lab1;
case 1:
// (, line 38
// <-, line 38
slice_from("a~");
break;
case 2:
// (, line 39
// <-, line 39
slice_from("o~");
break;
case 3:
// (, line 40
// next, line 40
if (cursor >= limit)
{
break lab1;
}
cursor++;
break;
}
continue replab0;
} while (false);
cursor = v_1;
break replab0;
}
return true;
} |
7fa375b6-c460-42bc-b8ec-86be0967b424 | 2 | private boolean withinBounds(int pointer, ArrayList<Rod> rodList) {
int currentLength = 0;
for(int i = 0; i < pointer; i++) {
currentLength += rodList.get(i).getLength();
}
return currentLength <= totalLength && pointer < rodList.size();
} |
12d64cd9-79d0-436c-b686-7a062a4629f7 | 6 | public static RelationTableInfo getRelationTableInfo(NamedDescription tablerelation) {
{ MemoizationTable memoTable000 = null;
Cons memoizedEntry000 = null;
Stella_Object memoizedValue000 = null;
if (Stella.$MEMOIZATION_ENABLEDp$) {
memoTable000 = ((MemoizationTable)(RDBMS.SGT_RDBMS_F_GET_RELATION_TABLE_INFO_MEMO_TABLE_000.surrogateValue));
if (memoTable000 == null) {
Surrogate.initializeMemoizationTable(RDBMS.SGT_RDBMS_F_GET_RELATION_TABLE_INFO_MEMO_TABLE_000, "(:MAX-VALUES 100 :TIMESTAMPS (:META-KB-UPDATE))");
memoTable000 = ((MemoizationTable)(RDBMS.SGT_RDBMS_F_GET_RELATION_TABLE_INFO_MEMO_TABLE_000.surrogateValue));
}
memoizedEntry000 = MruMemoizationTable.lookupMruMemoizedValue(((MruMemoizationTable)(memoTable000)), tablerelation, ((Context)(Stella.$CONTEXT$.get())), Stella.MEMOIZED_NULL_VALUE, null, -1);
memoizedValue000 = memoizedEntry000.value;
}
if (memoizedValue000 != null) {
if (memoizedValue000 == Stella.MEMOIZED_NULL_VALUE) {
memoizedValue000 = null;
}
}
else {
memoizedValue000 = RDBMS.createRelationTableInfo(tablerelation);
if (Stella.$MEMOIZATION_ENABLEDp$) {
memoizedEntry000.value = ((memoizedValue000 == null) ? Stella.MEMOIZED_NULL_VALUE : memoizedValue000);
}
}
{ RelationTableInfo value000 = ((RelationTableInfo)(memoizedValue000));
return (value000);
}
}
} |
9f318c4c-df4b-4aaa-b24c-687280a8bde4 | 8 | public QRDecomposition (Matrix A) {
// Initialize.
QR = A.getArrayCopy();
m = A.getRowDimension();
n = A.getColumnDimension();
Rdiag = new double[n];
// Main loop.
for (int k = 0; k < n; k++) {
// Compute 2-norm of k-th column without under/overflow.
double nrm = 0;
for (int i = k; i < m; i++) {
nrm = Maths.hypot(nrm,QR[i][k]);
}
if (nrm != 0.0) {
// Form k-th Householder vector.
if (QR[k][k] < 0) {
nrm = -nrm;
}
for (int i = k; i < m; i++) {
QR[i][k] /= nrm;
}
QR[k][k] += 1.0;
// Apply transformation to remaining columns.
for (int j = k+1; j < n; j++) {
double s = 0.0;
for (int i = k; i < m; i++) {
s += QR[i][k]*QR[i][j];
}
s = -s/QR[k][k];
for (int i = k; i < m; i++) {
QR[i][j] += s*QR[i][k];
}
}
}
Rdiag[k] = -nrm;
}
} |
9a2b9f35-9384-4d0a-8d14-c9b176721d1b | 0 | public String getName() {
return name;
} |
0ccd5685-fdfe-44ac-aba4-17bbc136287b | 2 | public void paintComponent(Graphics g)
{
// base
g.setColor(Color.black);
g.drawLine(centerX - width/2, centerY, centerX + width/2, centerY);
g.drawLine(centerX, centerY, centerX, centerY - height);
g.drawString(name, centerX - 5, centerY + 15);
for (int i = 0; i < disks.size(); i++) {
try {
int diskNo = getDiskNo(i);
int diskWidth = DISK_WIDTH_DELTA * diskNo;
int x = centerX - diskWidth/2;
int y = centerY - DISK_HEIGHT * (i + 1);
g.setColor(getColorForDisk(disks.elementAt(i)));
g.fillRect(x, y, diskWidth, DISK_HEIGHT);
g.setColor(Color.black);
g.drawString(String.valueOf(diskNo), x, y + DISK_HEIGHT - 1);
}
catch (ArrayIndexOutOfBoundsException ex) {
}
}
} |
23c6527b-8df3-4c61-817d-6d8f8937ddfd | 6 | @EventHandler
public void CaveSpiderHunger(EntityDamageByEntityEvent event) {
Entity e = event.getEntity();
Entity damager = event.getDamager();
String world = e.getWorld().getName();
boolean dodged = false;
Random random = new Random();
double randomChance = plugin.getCaveSpiderConfig().getDouble("CaveSpider.Hunger.DodgeChance") / 100;
final double ChanceOfHappening = random.nextDouble();
if (ChanceOfHappening >= randomChance) {
dodged = true;
} if (plugin.getCaveSpiderConfig().getBoolean("CaveSpider.Hunger.Enabled", true) && damager instanceof CaveSpider && e instanceof Player && plugin.getConfig().getStringList("Worlds").contains(world) && !dodged) {
Player player = (Player) e;
player.addPotionEffect(new PotionEffect(PotionEffectType.HUNGER, plugin.getCaveSpiderConfig().getInt("CaveSpider.Hunger.Time"), plugin.getCaveSpiderConfig().getInt("CaveSpider.Hunger.Power")));
}
} |
256c645e-fbda-463f-9efc-639c715ddcf1 | 5 | String change2str(ChangeEffect change) {
String str = effTranslate(change.getEffectType());
if (change.getCodonsOld().isEmpty() && change.getCodonsNew().isEmpty()) str += " -";
else str += " " + change.getCodonsOld() + "/" + change.getCodonsNew();
if (change.getAaOld().isEmpty() && change.getAaNew().isEmpty()) str += " -";
else if (change.getAaOld().equals(change.getAaNew())) str += " " + change.getAaNew();
else str += " " + change.getAaOld() + "/" + change.getAaNew();
return str;
} |
135bfe29-43b1-4f6b-b39a-e2e2eb670b33 | 1 | public void printObjectState(){
for(Map.Entry<String, Object> entry : objectManager.objects.entrySet()){
Object object = entry.getValue();
System.out.println(object.name + "has value: " + object.value);
}
} |
a5d8dca9-6c47-4761-81aa-05cb6550ebe6 | 7 | protected void validateBasicAuthentication(OAuth2Message message, OAuth2Accessor accessor)
throws IOException,OAuth2Exception {
String authz = message.getHeader("Authorization");
if (authz != null) {
if(authz.substring(0,5).equals("Basic")){
String userPass = new String(Base64.decodeBase64(authz.substring(6).getBytes()), "UTF-8");
int loc = userPass.indexOf(":");
if (loc == -1) {
OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.INVALID_CLIENT);
throw problem;
}
String userPassedIn = userPass.substring(0, loc);
String user = userPassedIn;
String pass = userPass.substring(loc + 1);
if(user!=null && pass!=null){
if (!user.equals(accessor.client.clientId)) {
OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.INVALID_CLIENT);
throw problem;
}else{
if(!pass.equals(accessor.client.clientSecret)){
OAuth2ProblemException problem = new OAuth2ProblemException(OAuth2.ErrorCode.INVALID_CLIENT);
throw problem;
}
return;
}
}
}
}
} |
2268f488-3a57-49fa-a037-9ec8c7de412f | 9 | private int alphabetaCardPicking(GameState state,
ArrayList<Color> playerList, ArrayList<Card> choiceList, int alpha, int beta, Color faction, int depth)
{
//Base case, if there aren't any more players we go to the first action
if(playerList.size() == 0)
{
GameState tempState = new GameState(state);
for(Card c : choiceList)
{
tempState.getPlayer(c.getFaction()).removeFromHand(c);
tempState.getBoard().addCard(c);
}
tempState.setTime(Time.DAY);
return alphabeta(tempState, alpha, beta, faction, depth);
}
else
{
//otherwise, we iterate through all the possibilities of a given player's card choices
Color pColor = playerList.remove(0);
if(faction.equals(pColor))
{
for(Card c : state.getPlayer(pColor).getHand())
{
ArrayList<Card> tempChoice = new ArrayList<Card>(choiceList);
tempChoice.add(c);
alpha = Math.max(alpha, alphabetaCardPicking(state, new ArrayList<Color>(playerList),
tempChoice, alpha, beta,
faction, depth));
if(alpha >= beta)
return alpha;
}
//we also need to check if they have no cards in their hand
if(state.getPlayer(pColor).getHand().isEmpty())
{
alpha = Math.max(alpha, alphabetaCardPicking(state, new ArrayList<Color>(playerList),
new ArrayList<Card>(choiceList), alpha, beta,
faction, depth));
}
return alpha;
}
else
{
for(Card c : state.getPlayer(pColor).getHand())
{
ArrayList<Card> tempChoice = new ArrayList<Card>(choiceList);
tempChoice.add(c);
beta = Math.min(beta, alphabetaCardPicking(state,
new ArrayList<Color>(playerList), tempChoice, alpha, beta,
faction, depth));
if(alpha >= beta)
return beta;
}
if(state.getPlayer(pColor).getHand().isEmpty())
{
beta = Math.min(beta, alphabetaCardPicking(state, new ArrayList<Color>(playerList),
new ArrayList<Card>(choiceList), alpha, beta,
faction, depth));
}
return beta;
}
}
} |
f9301742-d586-45ec-bd62-3656e3c0757d | 8 | private void estimateDistribution(int[] bowl, int bowlId, int round, int bowlSize){
// Initially, create a uniform distribution
for (int i=0; i < NUM_FRUITS ; i++) {
originalDistribution[i] = Math.round(n_fruits/NUM_FRUITS);
// Assign uniform probability
if (bowls_seen[0] == 0 || bowls_seen[1] == 0)
{
java.util.Arrays.fill(fruit_probs, 1.0 / NUM_FRUITS);
}
}
// Update fruit history as bowls come by
fruitHistory = history(bowl, bowlId, round);
bowls_seen[round]++;
if (bowls_seen[0] > 0 || bowls_seen[1] > 0)
{
// Update Probabilities
double prob_sum = 0.0;
for (int i = 0; i < NUM_FRUITS ; i++) {
fruit_probs[i] += (fruitHistory[round*n_players + bowlId][i]*1.0/bowlSize);
prob_sum += fruit_probs[i];
}
}
// generate a platter based on estimated probabilties of each fruit
for (int i=0; i < NUM_FRUITS ; i++) {
currentDistribution[i] = (int) Math.round(n_fruits * fruit_probs[i]);
}
for (int i=0; i < NUM_FRUITS ; i++) {
originalDistribution[i] -= currentDistribution[i];
}
} |
faa45143-c1e0-48dd-a580-02dd7f8fb632 | 9 | public List<String> fetchCategories(String userId, String type){
List<String> unsubCat = new ArrayList<String>();
ResultSet rs=null;
Connection con=null;
PreparedStatement ps=null;
List<String> result=new ArrayList<String>();
try{
String sql;
if(type.equals("NotSubscribed")){
sql="SELECT DISTINCT CATEGORY_NAME FROM CATEGORY cat WHERE CATEGORY_NAME "
+ "NOT IN (SELECT DISTINCT CATEGORY_NAME FROM CATEGORY cat WHERE CATEGORYID "
+ "IN (SELECT C_ID FROM STUDENT_CATEGORY_MAPPING WHERE S_ID IN "
+ "(SELECT DISTINCT S_ID FROM PERSON WHERE USERID=?)))";
}else{
sql="SELECT DISTINCT CATEGORY_NAME FROM CATEGORY cat WHERE CATEGORYID "
+ "IN (SELECT C_ID FROM STUDENT_CATEGORY_MAPPING WHERE S_ID IN "
+ "(SELECT DISTINCT S_ID FROM PERSON WHERE USERID=?))";
}
con=ConnectionPool.getConnectionFromPool();
ps=con.prepareStatement(sql);
ps.setString(1, userId);
rs=ps.executeQuery();
while(rs.next())
{
result.add(rs.getString("category_name"));
}
}
catch(Exception ex)
{
ex.printStackTrace();
}
finally{
if(rs!=null)
{
try {
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if(ps!=null)
{
try {
ps.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
if(con!=null)
{
try {
ConnectionPool.addConnectionBackToPool(con);;
} catch (Exception e) {
e.printStackTrace();
}
}
}
return result;
} |
136620ba-5c4b-4b8d-84a7-d56edc0e3630 | 5 | private static Color getColor(int selection) {
switch (selection) {
case RED:
return Color.RED;
case WHITE:
return Color.WHITE;
case YELLOW:
return Color.YELLOW;
case GREEN:
return Color.GREEN;
case BLUE:
default:
return Color.BLUE;
}
} |
913bfd39-6b0b-4821-a9a1-177801100b1a | 3 | private void key(byte key[]) {
int i;
int koffp[] = { 0 };
int lr[] = { 0, 0 };
int plen = P.length, slen = S.length;
for (i = 0; i < plen; i++)
P[i] = P[i] ^ streamtoword(key, koffp);
for (i = 0; i < plen; i += 2) {
encipher(lr, 0);
P[i] = lr[0];
P[i + 1] = lr[1];
}
for (i = 0; i < slen; i += 2) {
encipher(lr, 0);
S[i] = lr[0];
S[i + 1] = lr[1];
}
} |
bc511af5-a7d9-493d-a54d-337d8061942d | 2 | private void setFlag(State s, StateFlag flag) {
switch (flag) {
case INITIAL:
initialStates.add(s);
break;
case ACCEPT:
acceptStates.add(s);
}
} |
97bf3c37-d8b9-4945-a67a-95dcb173869b | 8 | @SuppressWarnings("unchecked")
public void init() throws Exception {
RecorderServlet.recording = Boolean.parseBoolean(server.prop
.getProperty("homecam.Capturer.recording"));
RecorderServlet.maxRecord = Integer.parseInt(server.prop
.getProperty("homecam.Capturer.maxRecord"));
RecorderServlet.recordedDirectory = server.prop
.getProperty("homecam.Capturer.recordedDirectory");
RecorderServlet.houseKeepDay = Integer.parseInt(server.prop
.getProperty("homecam.Capturer.houseKeepDay"));
Capturer.capturerTimeout = Integer.parseInt(server.prop
.getProperty("homecam.Capturer.capturerTimeout"));
Capturer.capturerSoftTimeout = Integer.parseInt(server.prop
.getProperty("homecam.Capturer.capturerSoftTimeout"));
CapturerImage.outputFormat = server.prop
.getProperty("homecam.Capturer.outputFormat");
Capturer.resolutions = new LinkedList<Resolution>();
String[] strRess = server.prop.getProperty(
"homecam.Capturer.outputResolution").split(",");
for (String strRes : strRess) {
Capturer.resolutions.add(new Resolution(strRes));
}
outputMime = server.prop.getProperty("homecam.Capturer.outputMime");
String[] excludedCaptureDevice = server.prop.getProperty(
"homecam.Capturer.excludedCaptureDevice").split(",");
excludedCaptureDevices = new HashSet<String>();
for (String ecd : excludedCaptureDevice) {
excludedCaptureDevices.add(ecd);
}
preferredCaptureDevice = server.prop
.getProperty("homecam.Capturer.preferredCaptureDevice");
CaptureSystemFactory factory = DefaultCaptureSystemFactorySingleton
.instance();
log.trace("factory {}", factory);
system = factory.createCaptureSystem();
log.trace("system {}", system);
system.init();
List<CaptureDeviceInfo> list = (List<CaptureDeviceInfo>) system
.getCaptureDeviceInfoList();
capturers = new LinkedHashMap<String, Capturer>(list.size() * 2);
for (CaptureDeviceInfo info : list) {
String c = info.getDeviceID();
if (excludedCaptureDevices.contains(c)) {
log.info("{} exclude {}", c, info.getDescription());
continue;
}
log.info("{} +++++++ {}", c, info.getDescription());
try {
CaptureStream captureStream = system.openCaptureDeviceStream(c);
Capturer cap = new Capturer(info, captureStream);
capturers.put(c, cap);
} catch (CaptureException e) {
log.error(c, e);
}
if (StringUtils.isEmpty(preferredCaptureDevice))
preferredCaptureDevice = info.getDeviceID();
}
if (capturers.get(preferredCaptureDevice) == null) {
preferredCaptureDevice = capturers.keySet().iterator().next();
} else if (!StringUtils.equals(preferredCaptureDevice, capturers
.keySet().iterator().next())) {
Map<String, Capturer> newlist = new LinkedHashMap<String, Capturer>(
list.size() * 2);
Capturer first = capturers.remove(preferredCaptureDevice);
newlist.put(preferredCaptureDevice, first);
newlist.putAll(capturers);
capturers = newlist;
}
} |
54fc9668-91fe-4de8-9721-9d45b646d51c | 0 | public int getLength() {
return this.length;
} |
3cadad70-0426-4550-ba72-89abf2cd1802 | 6 | public ProbChar[] determineCharaterProbability(Individual[] fitIndividuals) {
//keep track of the most probable character in each index of the individuals
ProbChar[] mostProbableChars = new ProbChar[TARGET_STRING.length()];
//keep track of the fitness of each character that we might have in each index
//changes for each array
ProbChar[] allCharProbabilities = new ProbChar[ALPHABET.length()];
//initialize the array
for(int i = 0; i < ALPHABET.length(); i++) {
allCharProbabilities[i] = new ProbChar(ALPHABET.charAt(i), INDIVIDUAL_POPULATION_SIZE);
}
//go through each index of the individuals
for(int indIndex = 0; indIndex < TARGET_STRING.length(); indIndex++) {
//reset all the ProbChars in allCharProbabilities
for(ProbChar f : allCharProbabilities) {
f.reset();
}
//adjust all the the FitChars in the array based on the current index of the fit individuals
for(Individual curInd : fitIndividuals) {
char curChar = curInd.getCharAt(indIndex);
ProbChar curProbChar = ProbChar.getProbCharFromArrar(allCharProbabilities, curChar);
curProbChar.addAppearance(curInd.getFitness());
}
//find the ProbChar with the highest probability of appearance
ProbChar mostProbChar = new ProbChar('a', INDIVIDUAL_POPULATION_SIZE);
for(ProbChar f : allCharProbabilities) {
if(f.getProbability() > mostProbChar.getProbability())
mostProbChar = new ProbChar(f);
}
//store the most probable ProbChar
mostProbableChars[indIndex] = mostProbChar;
}
return mostProbableChars;
} |
accf312b-6af9-4531-9d20-df5240bbcd25 | 4 | public void insertAbove(String filter) {
gui.addToHistory(filter);
if (filter != null && !filter.trim().equals("")) {
JList list = (JList) filterLists.elementAt(currentFilterIndex);
int i = list.getSelectedIndex();
if (i < 0) {
i = 0;
}
StringTokenizer tokenizer =
new StringTokenizer(filter, "|");
while (tokenizer.hasMoreTokens()) {
DefaultListModel model =
(DefaultListModel) list.getModel();
model.add(i++, tokenizer.nextToken().trim());
}
}
} |
3d1c42a0-8018-4991-83bf-3964c3843143 | 5 | public static void main(String[] args){
Document doc = null;
try {
doc = Jsoup.connect("http://lyrics.wikia.com/Adele:Rolling_In_The_Deep").get();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Cleaner cleaner = new Cleaner(new Whitelist().simpleText());
Document cleanDoc = cleaner.clean(doc);
String songLine="";
String allTextS = cleanDoc.toString();
String[] allText = allTextS.split("\n");
for (String line : allText) {
if(line.contains("They keep me thinking")) songLine = line;
}
String liryctSnippet = "There's a fire starting in my heartReaching";
int startindex = songLine.indexOf(liryctSnippet);
// String to be scanned to find the pattern.
String fullLyrics = songLine.substring(startindex);
String pattern = "[a-z][A-Z]";
// Create a Pattern object
Pattern r = Pattern.compile(pattern);
// Now create matcher object.
Matcher m = r.matcher(fullLyrics);
for(int i=0;i<30;i++)
if ( m.find()){
System.out.println("Found value from pattern: " + m.group(0) );
fullLyrics = fullLyrics.replace(m.group(0), m.group(0).charAt(0)+"\n"+m.group(0).charAt(1) );
}
System.out.println(fullLyrics);
} |
2acb0e4c-6202-4f9b-8f10-b45850461048 | 6 | AboutDialog( JDialog parent ) {
super( parent, Utils.getResource( "about" ), true );
Utils.setDialogIcon( this );
setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE );
Container content = getContentPane();
content.setLayout( new GridBagLayout() );
GridBagConstraints gbc = new GridBagConstraints();
gbc.weightx = 1;
gbc.insets = new Insets( 5, 5, 5, 5 );
gbc.gridwidth = GridBagConstraints.REMAINDER;
String licensee = null;
String license = null;
URL url = getClass().getResource( "/jortho-license.properties" );
if( url != null ) {
Properties props = new Properties();
try {
props.load( url.openStream() );
licensee = props.getProperty( "Licensee" );
license = props.getProperty( "License" );
} catch( IOException ex ) {
ex.printStackTrace();
}
}
if( licensee != null && licensee.length() > 0 && "Commercial License".equalsIgnoreCase( license ) ) {
// Commercial License
content.add( Utils.getLabel( "JOrtho - Commercial License" ), gbc );
content.add( Utils.getLabel( "Licensee: " + licensee ), gbc );
content.add( Utils.getLabel( "2005 - 2013 \u00a9 i-net software, Berlin, Germany" ), gbc );
} else {
// GPL License
content.add( Utils.getLabel( "JOrtho - GNU General Public License (GPL)" ), gbc );
content.add( Utils.getLabel( "2005 - 2013 \u00a9 i-net software, Berlin, Germany" ), gbc );
JLabel link = Utils.getLabel( "<html><u>http://www.inetsoftware.de/other-products/jortho</u></html>" );
content.add( link, gbc );
link.addMouseListener( new MouseAdapter() {
@Override
public void mouseClicked( MouseEvent e ) {
try {
Desktop.getDesktop().browse( new URI( "http://www.inetsoftware.de/other-products/jortho" ) );
} catch( Exception ex ) {
ex.printStackTrace();
}
}
} );
}
pack();
setLocationRelativeTo( parent );
} |
042d513c-89d5-4896-8376-3b976e58b728 | 0 | public String getCharSet() {
return charSet;
} |
74dd79e1-23aa-42f8-8f84-88388c591605 | 4 | public boolean execute(CommandSender sender, String identifier,
String[] args) {
List<Command> sortCommands = plugin.getCommandHandler().getCommands();
List<Command> commands = new ArrayList<Command>();
for (Command command : sortCommands) {
if (command.isShownOnHelpMenu()
&& DonorTitles.perms.has(sender, command.getPermission())) {
commands.add(command);
}
}
sender.sendMessage(FontFormat
.translateString("&c-----[ &fDonorTitles Help &c]-----"));
for (Command command : commands) {
sender.sendMessage(FontFormat.translateString("&a"
+ command.getUsage()));
}
return true;
} |
08f6957d-c5a4-49b0-a4cf-2385590c4e90 | 4 | public void clipSourceDest(CPRect srcRect, CPRect dstRect) {
// FIXME:
// /!\ dstRect bottom and right are ignored and instead we clip
// against the width, height of the layer. :/
//
// this version would be enough in most cases (when we don't need
// srcRect bottom and right to be clipped)
// it's left here in case it's needed to make a faster version
// of this function
// dstRect.right = Math.min(width, dstRect.left + srcRect.getWidth());
// dstRect.bottom = Math.min(height, dstRect.top + srcRect.getHeight());
// new dest bottom/right
dstRect.right = dstRect.left + srcRect.getWidth();
if (dstRect.right > width) {
srcRect.right -= dstRect.right - width;
dstRect.right = width;
}
dstRect.bottom = dstRect.top + srcRect.getHeight();
if (dstRect.bottom > height) {
srcRect.bottom -= dstRect.bottom - height;
dstRect.bottom = height;
}
// new src top/left
if (dstRect.left < 0) {
srcRect.left -= dstRect.left;
dstRect.left = 0;
}
if (dstRect.top < 0) {
srcRect.top -= dstRect.top;
dstRect.top = 0;
}
} |
f528b62f-ff0f-470e-b8ef-7d8c03518dc6 | 2 | @Override
public void huolehdi(){
h1.kiihdyta(tila.getKiihtyvyys1X(), tila.getKiihtyvyys1Y());
h2.kiihdyta(tila.getKiihtyvyys2X(), tila.getKiihtyvyys2Y());
for (Raaja raaja : h1.getRaajat()){
raaja.setLiikkuuko(tila.getKulmankasvatus(h1));
}
for (Raaja raaja : h2.getRaajat()){
raaja.setLiikkuuko(tila.getKulmankasvatus(h2));
}
h1.liiku();
h2.liiku();
} |
92cbf2d2-aaf0-4d68-96bc-f43f3bcd4681 | 2 | public int[] selectRandom(){
calculateMoleculeID(0,0, new int[0]);
ArrayList<Molecule> arr = new ArrayList<Molecule>();
Molecule selected = new Molecule();
int n;
double rand;
//Sorts THIS molecule into an array
arr = sortIntoArray(arr);
for(int i=0; i<arr.size(); i++){
//System.out.printf("%d\t", arr.get(i).getID());
n=i+1;
selected = (Math.random() <= (double)1/(double)n) ? arr.get(i) : selected;
//System.out.printf(""+Arrays.toString(arr.get(i).getMolID())+"\n");
}
//System.out.printf("\n");
return selected.getMolID();
} |
0b999d2a-fa1c-46d8-84b8-367441477432 | 3 | public void setCaracter(TCaracter node)
{
if(this._caracter_ != null)
{
this._caracter_.parent(null);
}
if(node != null)
{
if(node.parent() != null)
{
node.parent().removeChild(node);
}
node.parent(this);
}
this._caracter_ = node;
} |
a9a8fbf7-0422-4329-a946-8cf747ea6df0 | 3 | public String getServerVersion(String serverPropertyType, String serverVersionPath) throws Exception {
final Properties prop = new Properties();
URL svp = new URL(serverVersionPath);
InputStream input = svp.openStream();
try {
prop.loadFromXML(input);
} catch (IOException ex) {
ex.printStackTrace();
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
String version = prop.getProperty(serverPropertyType);
return version;
} |
5786198e-9322-4698-ab75-8610e73431b8 | 7 | @Override
public String runMacro(HTTPRequest httpReq, String parm, HTTPResponse httpResp)
{
final java.util.Map<String,String> parms=parseParms(parm);
final String last=httpReq.getUrlParameter("BEHAVIOR");
if(last==null)
return " @break@";
if(last.length()>0)
{
final Behavior B=CMClass.getBehavior(last);
if(B!=null)
{
final StringBuffer str=new StringBuffer("");
if(parms.containsKey("HELP"))
{
StringBuilder s=CMLib.help().getHelpText("BEHAVIOR_"+B.ID(),null,true);
if(s==null)
s=CMLib.help().getHelpText(B.ID(),null,true);
int limit=78;
if(parms.containsKey("LIMIT"))
limit=CMath.s_int(parms.get("LIMIT"));
str.append(helpHelp(s,limit));
}
String strstr=str.toString();
if(strstr.endsWith(", "))
strstr=strstr.substring(0,strstr.length()-2);
return clearWebMacros(strstr);
}
}
return "";
} |
0a227e08-b141-4715-8838-7ea61e198dd2 | 2 | public static void main(String[] args){
int total = 0;
for(int i=1;i<10000;i++){
if(isAmicable(i)){
total += i;
System.out.println(i);
}
}
System.out.println(total);
} |
0eb17da3-6b53-4c0d-bba9-7ab28a2985d6 | 6 | private static char[] removeFrontZero(char[] number, boolean minus) {
int i=0;
for(;i<number.length;i++) {
if(number[i]!='0' && number[i]!='\u0000') {
break;
}
}
if(i==number.length) {
return "0".toCharArray();
}
number = Arrays.copyOfRange(number, i, number.length);
if(minus){
number = Arrays.copyOf(number, number.length+1);
for(int j=number.length-2;j>=0;j--) {
number[j+1] = number[j];
}
number[0] = '-';
}
return number;
} |
8dbd1113-4547-4cf1-b0cd-8e8a9262be3e | 8 | private double painoArvo(int x, int y) {
if((x == 3 || x == 4) && (y == 3 || y == 4)) return 0.5;
if((x <= 5 && x >= 2) && (y <= 5 && y >= 2)) return 0.25;
return 0.0;
} |
cd6575b4-07c6-4453-a339-3c1a9aca13e1 | 7 | public void run() {
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
saver.savePref(Width, Height, winZoom);
System.exit(0);
}
});
long before;
long after;
long start;
init();
before = System.nanoTime();
while (!quit) {
start = System.nanoTime();
update.update(Width, Height, winZoom, Map, HMap, VMap, PMap, LMap, PrMap, VxMap, VyMap, OldPrMap, OldVxMap, OldVyMap, state);
if (var.active && state == 0) {//If drawing is active and we are in the game screen
if (var.Drawing) //If it should be drawing
draw.create_line(DrawX, DrawY, LastDrawX, LastDrawY, Size, Equipped, Width, Height, winZoom, Map, VMap, PMap, HMap, Shape);//Draw
} else {
if (wait < 1) {//If the wait time to draw is over
var.active = true;//Activate the drawing
wait = 40;//Reset the timer
} else {//If it can't draw and the timer is not up
wait -= 1;//Make the timer progress
}
}
LastDrawX = DrawX;//Update the drawing points
LastDrawY = DrawY;
after = System.nanoTime();
if(after - before > 40000000)
{
repaint();
before = System.nanoTime();
}
if(System.nanoTime() - start != 0)
var.PaintFPS = (int)(1000000000/(System.nanoTime() - start));
else
var.PaintFPS = 1337;
}
} |
17a3a881-5fda-4c47-9704-599d3d174de9 | 9 | public static int getRow(int selection) {
int row = 100;
// Calculates
if (selection == 1 || selection == 2 || selection == 3) {
row = 0;
}
if (selection == 4 || selection == 5 || selection == 6) {
row = 1;
}
if (selection == 7 || selection == 8 || selection == 9) {
row = 2;
}
return row;
} |
118c7a3b-e154-4464-bac4-ec75c15d9eb9 | 1 | public void setShowColumnDivider(boolean visible) {
if (visible != mShowColumnDivider) {
mShowColumnDivider = visible;
notify(TreeNotificationKeys.COLUMN_DIVIDER, Boolean.valueOf(mShowColumnDivider));
}
} |
1733d36c-cfdf-4ce9-800a-b11a6cf4669f | 5 | @Override
public void actionPerformed(ActionEvent e) {
JMenuItem menuItem = (JMenuItem)e.getSource();
if(menuItem == exitItem){
System.exit(0);
}
else if(menuItem == aboutItem){
JOptionPane.showMessageDialog(this, "Java PE reader v1.0.");
}
else if(menuItem == openItem){
openFileDialog.setVisible(true);
String filename = openFileDialog.getDirectory() + openFileDialog.getFile();
if(filename != null){
//Reset the screen
clear();
file = openFileDialog.getFile();
//Append the infromation of PE on lables
try{
ReadPEfile pe = new ReadPEfile(filename);
pe.open();
String h = pe.getHeader();
header.setText(h);
String o = pe.getOptionalHeater();
optional_header.setText(o);
String s = pe.getSection();
pe_section.setText(s);
String i = pe.getIconInfo();
show_icon_info.setText(i);
pe.loadIcon();
pe.close();
}
catch(IOException ex){
JOptionPane.showMessageDialog(this, "Error for opening the file!");
}
}
}
} |
75ddb6a9-ee52-4602-b942-888916b79af7 | 0 | public int getJaar() {
return jaar;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.