method_id
stringlengths 36
36
| cyclomatic_complexity
int32 0
9
| method_text
stringlengths 14
410k
|
---|---|---|
8ed1b8b1-7f40-43ec-bac7-bfbe3a0a6bc6 | 1 | @Override
protected TreeRow clone() {
try {
TreeRow other = (TreeRow) super.clone();
other.mParent = null;
other.mIndex = 0;
return other;
} catch (CloneNotSupportedException exception) {
return null; // Not possible
}
} |
aebe127b-a7ee-4640-9f27-77d8e1490801 | 2 | @Override
public void update(int delta) {
cube.move(SPEED*direction*delta,0, 0);
pos.add(SPEED*direction*delta,0, 0);
if(pos.x > 100){
pos.x = 100;
direction *= -1;
}
if(pos.x < -100){
pos.x = -100;
direction *= -1;
}
} |
917c6aaf-f770-419a-b60c-e0a5e71c4d28 | 6 | public static void stream_align(FlaggableCharacterString input_stream,
Vector<AlignmentTuple> alignments,
Vector<AlignmentTriplet> triplets) {
for (AlignmentTuple alignment : alignments) {
// copy strings
FlaggableCharacterString presented = alignment.getPresented();
FlaggableCharacterString trans = alignment.getTranscript();
FlaggableCharacterString new_presented = new FlaggableCharacterString(presented);
FlaggableCharacterString new_transcribed = new FlaggableCharacterString(trans);
FlaggableCharacterString new_input_stream = new FlaggableCharacterString(input_stream);
// align action of stream for aligned presented and transcribed
for (int i = 0; i < Math.max(new_transcribed.size(),
new_input_stream.size()); i++) {
// i < new_transcribed.size() and i < new_input_stream.size() not in pseudo code
if (i < new_transcribed.size() && new_transcribed.charAt(i).getSymbol() == '-') {
Util.insertInto(new_input_stream, i, new FlaggableCharacter('_'));
} else if ( i < new_input_stream.size() && !new_input_stream.get(i).isFlagged()) {
Util.insertInto(new_presented, i, new FlaggableCharacter('_'));
Util.insertInto(new_transcribed, i, new FlaggableCharacter('_'));
}
}
triplets.add(new AlignmentTriplet(new_presented, new_transcribed, new_input_stream));
}
} |
d1c3e644-6923-4c8d-b148-fbcc963a5aad | 3 | @Override
protected void UpdateProductPassingThrough()
{
List<Product> productsAtExit = new LinkedList();
for (NodeStartPoint entrancePoint : m_listNodeStartPoint)
{
for (Product product : entrancePoint.GetBallot().GetProduct())
{
if (ContainsProduct(productsAtExit, product.GetTypeProduct().GetName()))
{
UpdateProductQuantity(productsAtExit, product.GetTypeProduct().GetName(), product.GetQuantity());
}
else
{
productsAtExit.add(product);
}
}
}
m_listNodeEndPoint.get(0).SetBallot(new Ballot(productsAtExit));
} |
7d718f7d-1467-4190-83c1-b703b3cb592e | 3 | public boolean HasItemAmount(int itemID, int itemAmount) {
int playerItemAmountCount = 0;
for (int i=0; i<playerItems.length; i++)
{
if (playerItems[i] == itemID+1)
{
playerItemAmountCount = playerItemsN[i];
}
if(playerItemAmountCount >= itemAmount){
return true;}
}
return false;
} |
a3805fa4-5835-4de0-bbc3-31a1a2ea372c | 0 | public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext(
"applicationContext.xml");
IMusicBox musicBox = (IMusicBox) context.getBean("musicBox");
musicBox.play();
} |
71ff3e82-24ca-4de3-9915-bad3699abe4d | 8 | public boolean isHigherOnActivitySeries(Element element)
{
if((this.isMetal() && !element.isMetal()) || (!this.isMetal() && element.isMetal()))
System.err.println("isHigherOnActivitySeries - One element is a metal and the other isn't!");
if(this.equals(element))
System.err.println("isHigherOnActivitySeries - Both elements are the same!\t"+this+"\t"+element);
boolean foundThisFirst = false;
for(int i = 0; i < eActivitySeries.length; i++)
{
if(eActivitySeries[i] == protons)
{
foundThisFirst = true;
break;
}
if(eActivitySeries[i] == element.protons)
break;
}
return foundThisFirst;
} |
44b1c967-b655-4ee2-93ea-2126bea47e8f | 7 | public void handle(HttpExchange exchange) throws IOException {
OutputStream responseBody = exchange.getResponseBody();
Headers responseHeaders = exchange.getResponseHeaders();
responseHeaders.set("Content-Type", "text/plain");
exchange.sendResponseHeaders(200, 0);
switch(exchange.getRequestURI().toString()) {
case "/":
responseBody.write("Available paths:\n\n/play\n/pause\n/stop\n/next\n/prev\n/nextpause".getBytes());
break;
case "/play":
Runtime.getRuntime().exec("C:\\Program Files (x86)\\foobar2000\\foobar2000.exe /play");
responseBody.write("foobar now playing".getBytes());
break;
case "/pause":
Runtime.getRuntime().exec("C:\\Program Files (x86)\\foobar2000\\foobar2000.exe /pause");
responseBody.write("foobar now paused".getBytes());
break;
case "/stop":
Runtime.getRuntime().exec("C:\\Program Files (x86)\\foobar2000\\foobar2000.exe /stop");
responseBody.write("foobar now stopped".getBytes());
break;
case "/next":
Runtime.getRuntime().exec("C:\\Program Files (x86)\\foobar2000\\foobar2000.exe /next");
responseBody.write("foobar now playing next song".getBytes());
break;
case "/prev":
Runtime.getRuntime().exec("C:\\Program Files (x86)\\foobar2000\\foobar2000.exe /prev");
responseBody.write("foobar now playing previous song".getBytes());
break;
case "/nextpause":
Runtime.getRuntime().exec("C:\\Program Files (x86)\\foobar2000\\foobar2000.exe /next");
Runtime.getRuntime().exec("C:\\Program Files (x86)\\foobar2000\\foobar2000.exe /pause");
responseBody.write("foobar now playing next song".getBytes());
break;
default:
responseBody.write("Unknown path!".getBytes());
break;
}
responseBody.close();
} |
7d30fd50-f1b9-46ed-a1c5-f9a8433f7a03 | 5 | TreeNode buildTreeWithPreorderAndInorder(int[] preorder, int[] inorder,
int startPreOrder, int endPreOrder, int startInOrder, int endInOrder) {
// if startPreOrder out of range of preorder
if (startPreOrder >= preorder.length)
return null;
TreeNode root = new TreeNode(preorder[startPreOrder]);
int indexRootInOrder = startInOrder;
// find root in inorder
while (inorder[indexRootInOrder] != preorder[startPreOrder]
&& indexRootInOrder <= endInOrder) {
indexRootInOrder++;
}
int distance = indexRootInOrder - startInOrder;
if (indexRootInOrder > startInOrder) {
root.left = buildTreeWithPreorderAndInorder(preorder, inorder,
startPreOrder + 1, startPreOrder + distance, startInOrder,
indexRootInOrder - 1);
}
if (indexRootInOrder < endInOrder) {
root.right = buildTreeWithPreorderAndInorder(preorder, inorder,
startPreOrder + distance + 1, endPreOrder,
indexRootInOrder + 1, endInOrder);
}
return root;
} |
1f7670d7-ca9e-49c5-8f6f-dbc693fe069c | 8 | private void printJoins(Vector<LogicalJoinNode> js, PlanCache pc,
HashMap<String, TableStats> stats,
HashMap<String, Double> selectivities) {
JFrame f = new JFrame("Join Plan for " + p.getQuery());
// Set the default close operation for the window,
// or else the program won't exit when clicking close button
f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
f.setVisible(true);
f.setSize(300, 500);
HashMap<String, DefaultMutableTreeNode> m = new HashMap<String, DefaultMutableTreeNode>();
// int numTabs = 0;
// int k;
DefaultMutableTreeNode root = null, treetop = null;
HashSet<LogicalJoinNode> pathSoFar = new HashSet<LogicalJoinNode>();
boolean neither;
System.out.println(js);
for (LogicalJoinNode j : js) {
pathSoFar.add(j);
System.out.println("PATH SO FAR = " + pathSoFar);
String table1Name = Database.getCatalog().getTableName(
this.p.getTableId(j.t1Alias));
String table2Name = Database.getCatalog().getTableName(
this.p.getTableId(j.t2Alias));
// Double c = pc.getCost(pathSoFar);
neither = true;
root = new DefaultMutableTreeNode("Join " + j + " (Cost ="
+ pc.getCost(pathSoFar) + ", card = "
+ pc.getCard(pathSoFar) + ")");
DefaultMutableTreeNode n = m.get(j.t1Alias);
if (n == null) { // never seen this table before
n = new DefaultMutableTreeNode(j.t1Alias
+ " (Cost = "
+ stats.get(table1Name).estimateScanCost()
+ ", card = "
+ stats.get(table1Name).estimateTableCardinality(
selectivities.get(j.t1Alias)) + ")");
root.add(n);
} else {
// make left child root n
root.add(n);
neither = false;
}
m.put(j.t1Alias, root);
n = m.get(j.t2Alias);
if (n == null) { // never seen this table before
n = new DefaultMutableTreeNode(
j.t2Alias == null ? "Subplan"
: (j.t2Alias
+ " (Cost = "
+ stats.get(table2Name)
.estimateScanCost()
+ ", card = "
+ stats.get(table2Name)
.estimateTableCardinality(
selectivities
.get(j.t2Alias)) + ")"));
root.add(n);
} else {
// make right child root n
root.add(n);
neither = false;
}
m.put(j.t2Alias, root);
// unless this table doesn't join with other tables,
// all tables are accessed from root
if (!neither) {
for (String key : m.keySet()) {
m.put(key, root);
}
}
treetop = root;
}
JTree tree = new JTree(treetop);
JScrollPane treeView = new JScrollPane(tree);
tree.setShowsRootHandles(true);
// Set the icon for leaf nodes.
ImageIcon leafIcon = new ImageIcon("join.jpg");
DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
renderer.setOpenIcon(leafIcon);
renderer.setClosedIcon(leafIcon);
tree.setCellRenderer(renderer);
f.setSize(300, 500);
f.add(treeView);
for (int i = 0; i < tree.getRowCount(); i++) {
tree.expandRow(i);
}
if (js.size() == 0) {
f.add(new JLabel("No joins in plan."));
}
f.pack();
} |
75530a39-cad4-4293-93cc-bb2152bc639e | 4 | @Override
public void deserialize(Buffer buf) {
super.deserialize(buf);
partyType = buf.readByte();
if (partyType < 0)
throw new RuntimeException("Forbidden value on partyType = " + partyType + ", it doesn't respect the following condition : partyType < 0");
maxParticipants = buf.readByte();
if (maxParticipants < 0)
throw new RuntimeException("Forbidden value on maxParticipants = " + maxParticipants + ", it doesn't respect the following condition : maxParticipants < 0");
fromId = buf.readInt();
if (fromId < 0)
throw new RuntimeException("Forbidden value on fromId = " + fromId + ", it doesn't respect the following condition : fromId < 0");
fromName = buf.readString();
toId = buf.readInt();
if (toId < 0)
throw new RuntimeException("Forbidden value on toId = " + toId + ", it doesn't respect the following condition : toId < 0");
} |
0cda879e-3dd8-4c32-905b-98fc5e5da885 | 2 | public static void drawCircle(Graphics g, int centerX, int centerY, int radius, Color color) {
g.setColor(color);
int x, y, d, dE, dSE;
x = 0;
y = radius;
d = 1 - radius;
dE = 3;
dSE = -2*radius+5;
simetry(g, x, y, centerX, centerY);
while (y > x) {
if (d < 0) {
d += dE;
dE += 2;
dSE += 2;
x += 1;
} else {
d += dSE;
dE += 2;
dSE += 4;
x += 1;
y += -1;
}
simetry(g, x, y, centerX, centerY);
}
} |
d98e8298-ca84-4736-ac78-56d3fbe2464e | 6 | @Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
IdentNode other = (IdentNode) obj;
if (identName == null) {
if (other.identName != null)
return false;
} else if (!identName.equals(other.identName))
return false;
return true;
} |
767883a4-c7df-44a2-8670-54fb81060969 | 4 | public void ge_or_logical(TextArea area,SimpleNode node,String prefix,int cur_end_num,int if_or_while)throws SemanticErr{
int or_num = node.jjtGetNumChildren();
SimpleNode left = (SimpleNode)node.jjtGetChild(0);
if(or_num==1)or_last=2;
else or_last=-1;
ge_and_logical(area,left,prefix, cur_end_num,if_or_while);
if(or_num>1) {
for (int i = 2; i < or_num; ) {
or_last=0;
if(i==or_num-1)or_last=1;
String sub_prefix = prefix.substring(0,prefix.length()-2);
String instr =sub_prefix+ "lor.lhs.false"+String.valueOf(false_num)+":\n";
area.append(instr);
false_num =false_num+1;
SimpleNode right = (SimpleNode)node.jjtGetChild(i);
ge_and_logical(area,right,prefix,cur_end_num, if_or_while);
i=i+2;
}
}
//记录逻辑表达式走到什么位置,是否已经走到最后
or_last=0;
and_last=0;
} |
83ec3bac-8a75-4c23-9b5a-6bf6dbe271a4 | 9 | @Override
public int castingQuality(MOB mob, Physical target)
{
if(mob!=null)
{
if(target instanceof MOB)
{
final Room R=((MOB)target).location();
boolean found=false;
if(R!=null)
for(int r=0;r<R.numInhabitants();r++)
{
final MOB M=R.fetchInhabitant(r);
if((M!=null)&&(M!=mob)&&(M!=target)&&(CMLib.flags().isInvisible(M)))
{ found=true; break;}
}
if(!found)
return Ability.QUALITY_INDIFFERENT;
}
}
return super.castingQuality(mob,target);
} |
17a76cca-8620-47ad-9f26-cb107c78e8bf | 0 | public static String getStringValue(String attr) {
return prop.getProperty(attr);
} |
603460a6-f11d-4fda-9dce-4b5fdd8227d4 | 1 | public String getStatusFrequencyOverPartOfDay() {
Map<String, Integer> map = analytic.getStatusFrequencyOverPartOfDay();
StringBuilder sb = new StringBuilder();
List<Entry<String, Integer>> entries = new ArrayList<Entry<String, Integer>>(map.entrySet());
Collections.sort(entries, new Comparator<Entry<String, Integer>>() {
public int compare(Entry<String, Integer> o1, Entry<String, Integer> o2) {
return o2.getValue() - o1.getValue();
}
});
for(Entry<String, Integer> partOfDay : entries){
sb.append(partOfDay.getKey());
sb.append(" - ");
sb.append(partOfDay.getValue());
sb.append(NEWLINE);
}
return sb.toString();
} |
885fed9a-2f20-4f15-bf06-10f5738e2bf0 | 7 | double funct(double x[]) {
//RefreshDataHandles();
for (int j = 0; j < parameters.length; j++) {
try {
parameters[j] = x[j];
} catch (Exception e) {
throw new RuntimeException("Error! Parameter No. " + j + " wasn^t found" + e.toString());
}
}
// singleRun();
double value = effValue;
//sometimes its a bad idea to calculate with NaN or Infty
double bigNumber = 10000000;
effValue = Math.max(effValue, -bigNumber);
effValue = Math.min(effValue, bigNumber);
if (Double.isNaN(effValue)) {
effValue = -bigNumber;
}
currentSampleCount++;
switch (mode) {
case Statistics.MINIMIZATION:
return value;
case Statistics.MAXIMIZATION:
return -value;
case Statistics.ABSMINIMIZATION:
return Math.abs(value);
case Statistics.ABSMAXIMIZATION:
return -Math.abs(value);
default:
return 0.0;
}
} |
8ebc6dc4-202a-4264-90c8-a8fcc6cbb35d | 9 | protected boolean isPrimitiveValue(Object value)
{
return value instanceof String || value instanceof Boolean
|| value instanceof Character || value instanceof Byte
|| value instanceof Short || value instanceof Integer
|| value instanceof Long || value instanceof Float
|| value instanceof Double || value.getClass().isPrimitive();
} |
59b067fd-ec75-487a-9b60-2987e9ca3c4b | 0 | public String getPackageName() {
return this.packageName;
} |
99f1c171-074e-4e38-8783-555d6601e9c6 | 3 | public Document getDocument(String filePath){
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
Document document = null;
try{
//DOM parse instance
DocumentBuilder builder = builderFactory.newDocumentBuilder();
//parse an XML file into a DOM tree
document = builder.parse(filePath);//this.getClass().getResourceAsStream(filePath));
} catch (ParserConfigurationException e) {
e.printStackTrace();
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return document;
} |
a710a1eb-156e-4f0f-b6b8-09f3f4b531e3 | 0 | public Integer getTopDiskNo() {
return maxDisks - (disks.peek() - 1);
} |
7c06e9c2-a0d3-4204-93d9-9e3b56344d52 | 4 | @Override
public void close() {
if (readMonitor != stdin) {
try {
in.close();
} catch (IOException e) {
System.err.printf("Cannot close console input. %s: %s%n", getClass(), e.getMessage());
}
}
if (out != stdout) {
try {
out.close();
} catch (IOException e) {
System.err.printf("Cannot close console output. %s: %s%n", getClass(), e.getMessage());
}
}
} |
56de8d76-9cd1-4cb8-ac31-5d49a9a7bbfd | 7 | public void calculateStateSpace() {
/* Initialization */
PetriNet _net = petriNet;
//State _intialState=new State(_net.getState(), 0, null);
Trie _stateSpace = new Trie();
State _currentState;
State firstState;
firstState = new State(_net.getState(), 0, null, _net);
_currentState = new State(_net.getState(), 0, null, _net);
_stateSpace.insert(_currentState.getKey(), _currentState);
/* Calculation */
// System.out.println("***********************************************");
// System.out.println("***********************************************");
// System.out.println(_currentState);
while (_currentState != null) {
/* Add child states if transitions is activate */
for (Transition t : _net.getListOfTransitions()) {
_net.setState(_currentState);
ArrayList<Integer> candidates = t.isActive();
if (candidates != null) // return array of markings
{
/* Simulate execution of transition */
State temp = new State(_net.getState(), 0, _currentState.getParent(), _net);
//System.out.println("TRAN "+t.getName());
for (int i = 0; i < candidates.size(); i++) {
//System.out.println("CAND NUMB " + candidates.get(i));
t.executeTransition(i);
//System.out.println("CURR NUMB " + _currentState);
//_currentState = new State(temp.getPlaceMarkings(), temp.getLastMarkedItem(), temp.getParent(), _net);
//System.out.println("ACT "+_net.getState());
//System.out.println("TEMP "+temp);
/* If child state already exists in stateSpace , do nothing */
/* else add to parent's childs & add to stateSpace */
State _childState = new State(_net.getState(), 0, _currentState, _net);
/* Unique state add to childs and stateSpaces */
if (_stateSpace.insert(_childState.getKey(), _childState)) {
_currentState.addChild(new StateItem(_childState, t));
//_stateSpace.levelOrder();
//System.out.println("VKLADAM: " + _childState);
_net.setState(_currentState);
}
_net.setState(_currentState);
//System.out.println("STAV "+temp);
}
}
}
/* Can I execute any child? */
if (_currentState.getLastMarkedItem() < _currentState.getChilds().size()) {
//System.out.println("dalsi " + _currentState.getLastMarkedItem());
State _newState = _currentState.getChilds().get(_currentState.getLastMarkedItem()).getState();
_currentState.increaseLastMarkedItem();
_currentState = _newState;
//_stateSpace.levelOrder();
//System.out.println("CRUR po pridani "+_currentState);
//_currentState = new State(_newState.getPlaceMarkings(), 0, null);
} /* No child, go to parent */ else {
//System.out.println("otec");
_currentState = _currentState.getParent();
//System.out.println("NAVRAT HORE");
}
// End while (_currentState!=null)
}
// System.out.println("***********************************************");
// System.out.println("***********************************************");
/* Write results and revert back original net markings */
result=_stateSpace.levelOrder();
for(State s : result){
System.out.println(s);
}
_net.setState(firstState);
//_net.setState(_intialState);
} |
bda9ddff-46c0-4c41-b415-26dd5afb5c33 | 4 | private Boolean checkLookAndFeel(String name)
{
try {
UIManager.setLookAndFeel(name);
return true;
} catch (ClassNotFoundException ex) {
Logger.getLogger(Window.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(Window.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(Window.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedLookAndFeelException ex) {
Logger.getLogger(Window.class.getName()).log(Level.SEVERE, null, ex);
}
return false;
} |
bdb81076-d7b6-420f-bee3-0e6b3d457c11 | 3 | private void waitForThread() {
if ((this.thread != null) && this.thread.isAlive()) {
try {
this.thread.join();
} catch (final InterruptedException e) {
e.printStackTrace();
}
}
} |
8f618e25-f132-4baa-b658-ecc845dfbfb9 | 4 | public ArrayList<Usuarios> getByNombre(Usuarios u){
PreparedStatement ps;
ArrayList<Usuarios> usuarios = new ArrayList<>();
try {
ps = mycon.prepareStatement("SELECT * FROM Usuarios WHERE nombre LIKE ?");
ps.setString(1, "%"+u.getNombre()+"%");
ResultSet rs = ps.executeQuery();
if(rs!=null){
try {
while(rs.next()){
usuarios.add(
new Usuarios(
rs.getString("codigo"),
rs.getString("nombre"),
rs.getString("dni")
)
);
}
} catch (SQLException ex) {
Logger.getLogger(Usuarios.class.getName()).
log(Level.SEVERE, null, ex);
}
}else{
System.out.println("Total de registros encontrados es: 0");
}
} catch (SQLException ex) {
Logger.getLogger(UsuariosCRUD.class.getName()).log(Level.SEVERE, null, ex);
}
return usuarios;
} |
52af60e4-1082-49bc-aac3-aadb8adeda08 | 2 | private void newSolve(ArrayList<Solve> population, int ind1, int ind2) {
Random rand = new Random();
Solve a = population.get(ind1);
Solve b = population.get(ind2);
Solve c = new Solve();
Solve d = new Solve();
int j = rand.nextInt(chromosomesize);
for (int i = 0; i < j; i++) {
c.Colors.add(a.Colors.get(i));
d.Colors.add(b.Colors.get(i));
}
for (int i = j; i < chromosomesize; i++) {
c.Colors.add(b.Colors.get(i));
d.Colors.add(a.Colors.get(i));
}
c.ValueSolve(matr);
d.ValueSolve(matr);
population.set(ind1, c);
population.set(ind2, d);
} |
23c2864e-f394-4554-942f-666437ed2e26 | 1 | @Override
public boolean isObstacle(Element e) {
if (e instanceof PowerFailure)
return false;
return true;
} |
17403512-e3bf-4384-a2e5-d80f060a18eb | 9 | private boolean isMatch(final char current, final Element element) {
boolean rv = false;
if (element.isSpecial) {
switch(element.item) {
case '.':
rv = true;
break;
case 'd':
rv = Character.isDigit(current);
break;
case 'D':
rv = !Character.isDigit(current);
break;
case 's':
rv = Character.isWhitespace(current);
break;
case 'S':
rv = !Character.isWhitespace(current);
break;
case 'w':
rv = Character.isLetter(current);
break;
case 'W':
rv = !Character.isLetter(current);
break;
}
} else {
rv = element.item == current;
}
if ((options & Transliteration.OPTION_COMPLEMENT) == Transliteration.OPTION_COMPLEMENT) {
rv = !rv;
}
return rv;
} |
510313d2-a36f-4c29-8eae-f3129141618f | 5 | @SuppressWarnings({ "unchecked", "static-access" })
public static void readXml() {
try {
SAXReader saxReader = new SAXReader();
File file = new File(xml);
if (file.exists()) {
Document doc = saxReader.read(file);
Element rootEle = doc.getRootElement();
List<Element> list = (List<Element>) rootEle.elements(OFFER);
List<Product> proList = new ArrayList<Product>();
for (Element ele : list) {
Product product = new Product();
product.setSku(ele.attributeValue(SKU));
product.setName(ele.elementText(NAME));
product.setDescription(ele.elementText(DESCRIPTION));
product.setOnline(ele.elementText(ONLINE));
proList.add(product);
}
if (proList.size() > 0) {
ComparatorProduct compare = new ComparatorProduct();
compare.sort(proList);
Collections.sort(proList, compare);
for (int i = 0; i < proList.size(); i++) {
System.out.println("name:" + proList.get(i).getName()
+ " " + "sku:" + proList.get(i).getSku());
}
}
} else {
CreateProductXml.creadXml();
}
} catch (DocumentException e) {
e.printStackTrace();
}
} |
5615102f-9887-40ea-bef2-d717dbfe1fca | 6 | public ClassGeneratorUtil(Modifiers classModifiers, String className, String packageName, Class superClass, Class[] interfaces, Variable[] vars, DelayedEvalBshMethod[] bshmethods, NameSpace classStaticNameSpace, boolean isInterface) {
this.classModifiers = classModifiers;
this.className = className;
if (packageName != null) {
this.fqClassName = packageName.replace('.', '/') + "/" + className;
} else {
this.fqClassName = className;
}
if (superClass == null) {
superClass = Object.class;
}
this.superClass = superClass;
this.superClassName = Type.getInternalName(superClass);
if (interfaces == null) {
interfaces = new Class[0];
}
this.interfaces = interfaces;
this.vars = vars;
this.classStaticNameSpace = classStaticNameSpace;
this.superConstructors = superClass.getDeclaredConstructors();
// Split the methods into constructors and regular method lists
List consl = new ArrayList();
List methodsl = new ArrayList();
String classBaseName = getBaseName(className); // for inner classes
for (DelayedEvalBshMethod bshmethod : bshmethods) {
if (bshmethod.getName().equals(classBaseName)) {
consl.add(bshmethod);
} else {
methodsl.add(bshmethod);
}
}
this.constructors = (DelayedEvalBshMethod[]) consl.toArray(new DelayedEvalBshMethod[consl.size()]);
this.methods = (DelayedEvalBshMethod[]) methodsl.toArray(new DelayedEvalBshMethod[methodsl.size()]);
try {
classStaticNameSpace.setLocalVariable(BSHCONSTRUCTORS, constructors, false/* strict */);
} catch (UtilEvalError e) {
throw new InterpreterError("can't set cons var");
}
this.isInterface = isInterface;
} |
5797554b-f566-4028-b79b-63f3b6ebe4c5 | 1 | public Boolean update(String query) {
if(autoCommit){
return updateIntern(query, false);
}
this.queries += query+="\n";
return null;
} |
fa5103cf-2f96-4b86-88f3-00bf4749c4de | 8 | private void quaff()
{
Grid<GridActor> gr = getGrid();
Location loc = getLocation(); // stores the current location of player
Location next = loc.getAdjacentLocation(0); // it chooses up by default
if(Greenfoot.isKeyDown("right") || Greenfoot.isKeyDown("l")) // player chooses right
{
next = loc.getAdjacentLocation(90); // gets actor to the east
}
if(Greenfoot.isKeyDown("down") || Greenfoot.isKeyDown("k")) // player chooses down
{
next = loc.getAdjacentLocation(180); // gets actor to the south
}
if(Greenfoot.isKeyDown("left") || Greenfoot.isKeyDown("h")) // player chooses left
{
next = loc.getAdjacentLocation(270); // gets actor to the west
}
GridActor neighbor = gr.get(next);
if(neighbor instanceof Fountain)
{
setText("You drink from the muddy water.\n");
// chooses your "reward"
double prob = Math.random() * luck;
if(prob < 0.2)
{
addToText("The water goes up your nose and you lose 1 hp!\n");
takeDamage(1);
}
getWorld().addObject(getMsgbox(), 36, 5); // display at coordinates of your choice
}
} |
60bd7a31-1b8f-43d6-98f6-baaf7485728b | 3 | public Tree andExpressionPro(){
Tree firstConditionalExpression = null, secondConditionalExpression = null;
Symbol operator = null;
if((firstConditionalExpression = equalityExpressionPro()) != null){
if((operator = accept(Symbol.Id.PUNCTUATORS,"&&")) != null){
if((secondConditionalExpression = andExpressionPro()) != null){
return new BinaryExpression(firstConditionalExpression,
operator, secondConditionalExpression);
}
return null;
}
return firstConditionalExpression;
}
return null;
} |
fb1b36f8-64d1-44e2-8df0-7a2e66825af1 | 9 | private boolean canProceed() throws SSLException {
while (true) {
switch (mEngine.getHandshakeStatus()) {
case NEED_TASK:
runSSLTasks();
break;
case NEED_UNWRAP:
switch (mEngine.unwrap(mInboundData, mAppData).getStatus()) {
case BUFFER_OVERFLOW:
resizeAppDataBuffer();
break;
case BUFFER_UNDERFLOW:
return false;
case CLOSED:
throw new SSLException("Connection closed (unwrap)");
default:
break;
}
break;
case NEED_WRAP:
switch (mEngine.wrap(EMPTY_BUFFER, mOutboundData).getStatus()) {
case BUFFER_UNDERFLOW:
// Should not be possible
throw new SSLException("Buffer underflow during handshake wrap");
case CLOSED:
throw new SSLException("Connection closed (wrap)");
default:
break;
}
sendOutboundData();
break;
default:
return true;
}
}
} |
d5cbd811-8bc9-4e94-876b-c361e69fa25c | 0 | public int getCapacity() {
return buf.length;
} |
f5684a02-3eab-4b17-b980-7b224b199a4f | 5 | private boolean isRepairMats(ItemStack i) {
if(i.getData().getItemType().equals(Material.WOOD))
return true;
if(i.getData().getItemType().equals(Material.STONE))
return true;
if(i.getData().getItemType().equals(Material.IRON_INGOT))
return true;
if(i.getData().getItemType().equals(Material.GOLD_INGOT))
return true;
if(i.getData().getItemType().equals(Material.DIAMOND))
return true;
return false;
} |
3a4ffc4a-fb7a-4bf6-9880-34f91eeaa43a | 7 | public static void main(String[] args) {
if (System.console() == null) {
System.err.println("Error: Not connected to compatible console");
System.exit(1);
}
File rc = new File(System.getProperty("user.home"), ".acmbotrc");
boolean firstTime = !rc.exists();
SmartBot bot = new SmartBot(rc.getAbsolutePath(),
new Module[]{
new DiceModule(),
new SarcasmModule(),
new CatfactsModule(),
new GreetModule(),
new DateTimeModule(),
new GamblerModule()
});
if (firstTime) {
firstTimeSetup(bot);
}
String extraMsg = "";
for (String s : args) {
if (!parseOption(s, bot)) {
extraMsg = s;
}
}
bot.setStartupMessage(extraMsg);
bot.enableModulesFromSettings();
bot.setVerbose(true);
try {
boolean connected = false;
while (!connected) {
try {
bot.connect();
connected = true;
} catch (ConnectException e) {
}
}
} catch (Exception e) {
e.printStackTrace();
}
} |
faf1841c-4f65-4157-8745-91bf04bfb2cc | 9 | private boolean containsPrefixHelper(String s, int indexLow, int indexMid, int indexHigh){
if(LexiconArrayList.get(indexLow).startsWith(s) || LexiconArrayList.get(indexMid).startsWith(s) || LexiconArrayList.get(indexHigh).startsWith(s)){
return true;
}else if(s.compareTo(LexiconArrayList.get(indexLow)) < 0 || s.compareTo(LexiconArrayList.get(indexHigh)) > 0){
return false;
}else if(s.compareTo(LexiconArrayList.get(indexMid)) > 0 && s.compareTo(LexiconArrayList.get(indexHigh)) < 0){
indexMid++;
indexHigh--;
return containsPrefixHelper(s, indexMid, ((indexMid+indexHigh)/2) ,indexHigh);
}else if(s.compareTo(LexiconArrayList.get(indexMid)) < 0 && s.compareTo(LexiconArrayList.get(indexLow)) > 0){
indexLow++;
indexMid--;
return containsPrefixHelper(s, indexLow, ((indexLow+indexMid)/2) ,indexMid);
}
return false;
} |
9a9fc44f-1005-4387-bcd0-f5a879387f4a | 9 | @SuppressWarnings("unchecked")
WeekView(JFrame parent){
first = false;
// Sets look to that of the OS
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (ClassNotFoundException e) {
}
catch (InstantiationException e) {
}
catch (IllegalAccessException e) {
}
catch (UnsupportedLookAndFeelException e) {
}
// Setting up of basic calendar attributes
theParent = parent;
mainFrame = new JFrame("Week View");
month = new JLabel("Week of September 29th");
month.setFont(new Font("Serif", Font.PLAIN, 18));
prev = new JButton("<-");
next = new JButton("->");
backToMain = new JButton("Return to Menu");
calendarTable = new DefaultTableModel()
{
public boolean isCellEditable(int rowIndex, int mColIndex)
{
return false;
}
};
theCalendar = new JTable(calendarTable);
calendarScroll = new JScrollPane(theCalendar);
calendarPanel = new JPanel(null);
mainFrame.setSize(900,750);
thePane = mainFrame.getContentPane();
thePane.setLayout(null);
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
calendarPanel.setBorder(BorderFactory.createTitledBorder("Calendar"));
thePane.add(calendarPanel);
calendarPanel.add(month);
calendarPanel.add(prev);
calendarPanel.add(next);
calendarPanel.add(calendarScroll);
calendarPanel.add(backToMain);
// Sets bounds of many attributes of the calendar
calendarPanel.setBounds(0, 0, 873, 670);
month.setBounds(320-month.getPreferredSize().width/2, 50, 200, 50);
prev.setBounds(20, 50, 100, 50);
next.setBounds(721, 50, 100, 50);
calendarScroll.setBounds(20, 100, 800, 500);
backToMain.setBounds(345, 610, 160, 40);
mainFrame.setResizable(false);
mainFrame.setVisible(true);
// Creates calendar to allow for correct day population
GregorianCalendar gregCal = new GregorianCalendar();
theDay = gregCal.get(GregorianCalendar.DAY_OF_MONTH);
theMonth = gregCal.get(GregorianCalendar.MONTH);
theYear = gregCal.get(GregorianCalendar.YEAR);
otherDay = theDay;
otherMonth = theMonth;
otherYear = theYear;
// Array that holds days of the week
theCalendar.setFont(new Font("Serif", Font.PLAIN, 18));
String[] days = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
for (int i = 0; i < 7; i++){
calendarTable.addColumn(days[i]);
}
// More various settings
theCalendar.getParent().setBackground(theCalendar.getBackground());
theCalendar.getTableHeader().setResizingAllowed(false);
theCalendar.getTableHeader().setReorderingAllowed(false);
theCalendar.setColumnSelectionAllowed(true);
theCalendar.setRowSelectionAllowed(true);
theCalendar.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
theCalendar.setRowHeight(456);
calendarTable.setColumnCount(7);
calendarTable.setRowCount(1);
// Adds listeners to the week view
prev.addActionListener(new prevWeek());
next.addActionListener(new nextWeek());
backToMain.addActionListener(new backToMenu());
final StoreData data = new StoreData();
// Listener that is added to each cell for a day
theCalendar.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent clicked) {
SendToDB newRun = new SendToDB();
int row = theCalendar.rowAtPoint(clicked.getPoint());
int col = theCalendar.columnAtPoint(clicked.getPoint());
if (row >= 0 && col >= 0) {
String selectedData = null;
String selectedMonth = null;
selectedData = (String) theCalendar.getValueAt(row, col);
selectedMonth = selectedData.substring(6,8);
selectedData = selectedData.substring(9, 11);
if(otherMonth < 10){
data.setDate("0"+selectedMonth+"-"+selectedData+"-"+otherYear);
}else{
data.setDate(""+selectedMonth+"-"+selectedData+"-"+otherYear);
}
newRun.runStore(data, 5);
// Shows the empty day dialog
if(data.getSingleDay().size() == 0){
EmptyDay newEmpty = new EmptyDay(data,theParent,data.getSingleDay().size());
// Shows the events for a day
}else{
DayView newDay = new DayView(data,theParent,data.getSingleDay().size());
}
}
}
});
updateCalendar(theDay, theMonth, theYear);
} |
2ea14a29-1493-48da-a741-7fdafa339cd0 | 2 | @EventHandler(priority = EventPriority.NORMAL)
public void onEntityChangeBlock(EntityChangeBlockEvent event) {
if (event.isCancelled())
return;
// plugin.debug(event.getEventName());
Block block = event.getBlock();
if (plugin.isProtected(block)) {
event.setCancelled(true);
plugin.debug("Blocking enty change block at " + event.getBlock().getWorld().getName() + " " + event.getBlock().getX() + " "
+ event.getBlock().getY() + " " + event.getBlock().getZ());
return;
}
} |
ed7aa88c-2ffb-4f2c-9a24-77e2e4af66d3 | 7 | public void comen2(char []codigo){
int let=0;
//Para eliminar el comentario /*
while(let<codigo.length-1){
if(codigo[let]=='/' && codigo[let+1]=='*'){
codigo[let] = ' ';
codigo[let+1] = ' ';
let++;
let++;
while(let<(codigo.length-1)){
if(!(codigo[let]=='*' && codigo[let+1]=='/')){
codigo[let] = ' ';
let++;
}else{
codigo[let] = ' ';
codigo[let+1] = ' ';
let=codigo.length;
}
}
if(let<codigo.length){
codigo[let]=' ';
codigo[let-1]=' ';
}
}
else{let++;}
}
} |
21deb0fb-96ba-4d23-8cc8-965f6324beb6 | 7 | private InfoDetail firstGranateForMe (InfoDetail me, List<InfoDetail> granates){
if(granates.isEmpty()){
return null;
}
InfoDetail granat=null;
for(int i=0; i<granates.size(); i++){
if(isForMe(me, granates.get(i))){
granat=granates.get(i);
break;
}
}
if(granat==null){
return null;
}
for(int i=0; i<granates.size(); i++){
if(isForMe(me, granates.get(i)) && distanceFrom(granates.get(i), me)<distanceFrom(granat, me)){
granat=granates.get(i);
}
}
return granat;
} |
cba07b98-ec04-40b5-b165-0a723839c2e9 | 0 | public static void question8() {
/*
QUESTION PANEL SETUP
*/
questionLabel.setText("Which of these words best describe you?");
questionNumberLabel.setText("8");
/*
ANSWERS PANEL SETUP
*/
//resetting
radioButton1.setSelected(false);
radioButton2.setSelected(false);
radioButton3.setSelected(false);
radioButton4.setSelected(false);
radioButton5.setSelected(false);
radioButton6.setSelected(false);
radioButton7.setSelected(false);
radioButton8.setSelected(false);
radioButton9.setSelected(false);
radioButton10.setSelected(false);
radioButton11.setSelected(false);
radioButton12.setSelected(false);;
radioButton13.setSelected(false);
radioButton14.setSelected(false);
//enability
radioButton1.setEnabled(true);
radioButton2.setEnabled(true);
radioButton3.setEnabled(true);
radioButton4.setEnabled(true);
radioButton5.setEnabled(false);
radioButton6.setEnabled(false);
radioButton7.setEnabled(false);
radioButton8.setEnabled(false);
radioButton9.setEnabled(false);
radioButton10.setEnabled(false);
radioButton11.setEnabled(false);
radioButton12.setEnabled(false);
radioButton13.setEnabled(false);
radioButton14.setEnabled(false);
//setting the text
radioButton1.setText("Economical");
radioButton2.setText("Good fun comes with good price.");
radioButton3.setText("Reckless");
radioButton4.setText("I'm all of the above. Depends on the situation");
radioButton5.setText("No used");
radioButton6.setText("No used");
radioButton7.setText("No used");
radioButton8.setText("No used");
radioButton9.setText("No used");
radioButton10.setText("No used");
radioButton11.setText("No used");
radioButton12.setText("No used");
radioButton13.setText("No used");
radioButton14.setText("No used");
// Calculating the best guesses and showing them.
Knowledge.calculateAndColorTheEvents();
} |
dd349b8c-3595-4141-af93-000fd88679bb | 8 | public int getTexture(String par1Str)
{
TexturePackBase var2 = this.texturePack.selectedTexturePack;
Integer var3 = (Integer)this.textureMap.get(par1Str);
if (var3 != null)
{
return var3.intValue();
}
else
{
try
{
if (Tessellator.renderingWorldRenderer)
{
System.out.printf("Warning: Texture %s not preloaded, will cause render glitches!\n", par1Str);
}
this.singleIntBuffer.clear();
GLAllocation.generateTextureNames(this.singleIntBuffer);
int var6 = this.singleIntBuffer.get(0);
if (par1Str.startsWith("##"))
{
this.setupTexture(this.unwrapImageByColumns(this.readTextureImage(var2.getResourceAsStream(par1Str.substring(2)))), var6);
}
else if (par1Str.startsWith("%clamp%"))
{
this.clampTexture = true;
this.setupTexture(this.readTextureImage(var2.getResourceAsStream(par1Str.substring(7))), var6);
this.clampTexture = false;
}
else if (par1Str.startsWith("%blur%"))
{
this.blurTexture = true;
this.setupTexture(this.readTextureImage(var2.getResourceAsStream(par1Str.substring(6))), var6);
this.blurTexture = false;
}
else if (par1Str.startsWith("%blurclamp%"))
{
this.blurTexture = true;
this.clampTexture = true;
this.setupTexture(this.readTextureImage(var2.getResourceAsStream(par1Str.substring(11))), var6);
this.blurTexture = false;
this.clampTexture = false;
}
else
{
InputStream var7 = var2.getResourceAsStream(par1Str);
if (var7 == null)
{
this.setupTexture(this.missingTextureImage, var6);
}
else
{
this.setupTexture(this.readTextureImage(var7), var6);
}
}
this.textureMap.put(par1Str, Integer.valueOf(var6));
ForgeHooksClient.onTextureLoad(par1Str, var6);
return var6;
}
catch (Exception var5)
{
var5.printStackTrace();
GLAllocation.generateTextureNames(this.singleIntBuffer);
int var4 = this.singleIntBuffer.get(0);
this.setupTexture(this.missingTextureImage, var4);
this.textureMap.put(par1Str, Integer.valueOf(var4));
return var4;
}
}
} |
9233298c-29fa-4302-bd10-e56bed0451ad | 4 | public String GrepUniqueID(String searchLink){
/*
* Gets the unique file ID (used to generate a .torrent location)
* This method also take server load/latency into account
*/
int searchLinkStart = 0;
int searchLinkEnd = 0;
int attempts = 0;
String uniqueID = "0000000000000000"; //loop atleast once.
String searchPage;
try {
while(uniqueID.length() > 15 ){
attempts++;
if (attempts >= 5)
return null; //exit if we are in this loop for over 5 iterations
searchPage = super.getWebPageHTTP(searchLink);
searchLinkStart = searchPage.indexOf("torrent_details") +16 ;
int i = 0;
searchLinkEnd = searchLinkStart;
while(searchPage.charAt(searchLinkEnd) + i != '/' )
searchLinkEnd++;
uniqueID = searchPage.substring(searchLinkStart, searchLinkEnd);
}
return uniqueID;
}catch(Exception e){
return null;
}
} |
b9262f50-f133-4044-a4d2-26ed1da64d1d | 3 | private static Long getMaxColumnProduct(int numbers) {
int max = Integer.MIN_VALUE;
for (int c = 0; c < DATA[0].length; c++) {
for (int r = 0; r + numbers < DATA.length; r++) {
int sum = 1;
for (int offset = 0; offset < numbers; offset++) {
sum *= DATA[r + offset][c];
}
max = Math.max(max, sum);
}
}
return (long) max;
} |
04124512-12af-43ee-90e1-a4acb7ef4ce6 | 9 | @Override
public void run() {
int size = 1024;
GZIPOutputStream gzipOutputStream = null;
try {
gzipOutputStream = new GZIPOutputStream(this.output, size);
} catch (IOException e1) {
System.err.println("\t\t\tFileCompress:IOException occurred while instantiating the GZIPOutputStream.");
this.finished = true;
return;
}
int len;
byte[] buff = new byte[size];
while (!finished && !suspending) {
try {
len = input.read(buff);
if (len > 0) {
gzipOutputStream.write(buff, 0, len);
} else {
this.finished = true;
}
} catch (IOException e) {
//TODO
e.printStackTrace();
this.finished = true;
break;
}
if (this.sleepSlot == 0) {
continue;
}
try {
Thread.sleep(this.sleepSlot);
} catch (InterruptedException e) {
//TODO:
e.printStackTrace();
this.finished = true;
break;
}
}
try {
if (this.finished) {
input.close();
output.close();
}
gzipOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
this.suspending = false;
return;
} |
bf65d76a-195f-44ac-8d33-67204394c531 | 0 | public AutomatonPane getView(){
return myView;
} |
f36c0ae4-c1a5-415a-868d-b3ec351d2c40 | 0 | public SintomaFacade() {
super(Sintoma.class);
} |
c5228501-736d-4103-afd3-55ff14c054bd | 1 | public boolean equals(Vector2f r)
{
return m_x == r.GetX() && m_y == r.GetY();
} |
fcdd155a-997a-423d-a3df-85b8c76658fc | 5 | public String getInsertStatement(String book, int chapter) throws ParseException, IOException {
// String strBook = String.format("B%02d", book);
// String strChapter = String.format("C%03d", chapter);
// String strHtml = getOneChapterHtmlSource(ver, getBook/home/mark/bible/checking/bgpda/hb_1_0Chapter("Matt", 6));
String strHtml = "TODO";
int verse = 0;
Document doc = Jsoup.parse(strHtml);
Elements testing = doc.select("P");
StringBuilder sb = new StringBuilder();
sb.append("\nINSERT INTO `bible`.`bible` (`VERSION`, `BOOK`, `CHAPTER`, `VERSE`, `CONTENT`) VALUES");
for (Element src : testing) {
//
// filter out
//
if (src.toString().contains("<a href=")) {
continue;
}
if (src.toString().length() <= 7) {
continue;
}
if (src.toString().contains("<img src")) {
continue;
}
if (src.toString().contains("<p> </p>")) {
continue;
}
//
// replace
//
String plain;
plain = src.toString().replace("<p>", "");
plain = plain.replace("</p>", "");
plain = plain.replace("<i>", "");
plain = plain.replace("</i>", "");
//
// compose SQL
//
verse++;
// System.out.println("ver="+ver+" book"+book+" chapter="+chapter+" "+verse + "=> " + plain);
String temp = String.format("%n('tw','%s','%s','%s','%s'),", book, chapter, verse, plain);
sb.append(temp);
// System.out.println(temp);
}
sb.deleteCharAt(sb.length() - 1);
sb.append(";");
// System.out.println(sb.toString());
return sb.toString();
} |
441913ce-ea02-47d6-a2d2-0292f2dfc28f | 7 | private void processAuctionEvent(AuctionEvent event) {
if (event.getType().equals(AuctionEvent.AUCTION_STARTED)) {
auctionList.add(event);
}
if (event.getType().equals(AuctionEvent.AUCTION_ENDED)) {
// AVG- Duration
if (avgAuctionDurationTimeEvent == null) {
Timestamp currentTimestamp = new Timestamp(
System.currentTimeMillis());
long timestamp = currentTimestamp.getTime();
try {
avgAuctionDurationTimeEvent = new StatisticsEvent(
StatisticsEvent.AUCTION_TIME_AVG, timestamp, 0);
} catch (WrongEventTypeException e) {
logger.error("Error: Wrong Eventtype accured");
}
}
double avgDuration = (avgAuctionDurationTimeEvent.getValue()
* aucitonDuration_multiplicator + event.getDuration())
/ (++aucitonDuration_multiplicator);
avgAuctionDurationTimeEvent.setValue(avgDuration);
notifyManagementClients(avgAuctionDurationTimeEvent);
// Auction- Sucess- Ratio
auctionCounter++;
if (!event.getWinner().equals("none")) {
auctionsSuceded++;
}
if (auctionSucessRatioEvent == null) {
Timestamp currentTimestamp = new Timestamp(
System.currentTimeMillis());
long timestamp = currentTimestamp.getTime();
try {
auctionSucessRatioEvent = new StatisticsEvent(
StatisticsEvent.AUCTION_SUCCESS_RATIO, timestamp, 0);
} catch (WrongEventTypeException e) {
logger.error("Error: Wrong Eventtype accured");
}
}
// in percent
auctionSucessRatioEvent.setValue(100 / auctionCounter
* auctionsSuceded);
notifyManagementClients(auctionSucessRatioEvent);
}
} |
4c3a15ed-2e36-4f68-8343-2aaf3f6975e2 | 5 | public void startRippingSelected() {
if(getTabel().isTHSelected()) {
Stream[] streamsToRecord = table.getSelectedStream();
for( int i=0 ; i <streamsToRecord.length; i++) {
if (streamsToRecord[i] == null) {
JOptionPane.showInputDialog(trans.getString("exeError"));
} else {
if(!streamsToRecord[i].getStatus()) {
Process p = getControlStream().startStreamripper(streamsToRecord[i]);
if(p == null) {
JOptionPane.showMessageDialog(Gui_StreamRipStar.this,trans.getString("exeError"));
SRSOutput.getInstance().logE("Error while exec streamripper");
} else {
streamsToRecord[i].increaseRippingCount();
streamsToRecord[i].setProcess(p);
streamsToRecord[i].setStatus(true);
Thread_UpdateName updateName = new Thread_UpdateName(streamsToRecord[i],getTabel().getSelectedRow(),getTabel());
updateName.start();
streamsToRecord[i].setUpdateName(updateName);
}
}
}
}
}
else
JOptionPane.showMessageDialog(Gui_StreamRipStar.this
,trans.getString("select"));
} |
eb4348e4-b838-4d6e-855e-ad5d91ad8225 | 5 | @Override
public String getTableName(String fileName) {
String line = "";
log.info("Start to read table name in "+fileName+"... ...");
//GET Table Name
try {
FileReader fr = new FileReader(new File(artificialFolderPath+"/"+fileName));
BufferedReader br = new BufferedReader(fr);
//#后为TableName
while ((line = br.readLine()) != null) {
if(line.startsWith("rem")){
continue;
}
else if (line.startsWith("#")){
tableName = line.substring(1);
}
}
if(br != null){
br.close();
}
} catch (IOException e1) {
log.error(e1.getLocalizedMessage());
}
return tableName;
} |
e90091c4-3167-4678-89de-78b5b1bdd476 | 1 | @Override
public void actionPerformed(ActionEvent e) {
JButton reduire = (JButton) e.getSource();
System.out.println("Reduire vitesse");
new Thread(new Runnable() {
public void run() {
try { Main.service.diminuerVitesse(bus); }
catch (IOException e) { e.printStackTrace(); }
}
}).start();
} |
582d57b2-f68b-4522-8458-110a714edf19 | 3 | @Override
public void open() throws AudioException {
super.open();
DataLine.Info info = new DataLine.Info(
this.mTargetDataLineClass,
this.mAudioFormat
);
try {
if ( !this.mMixer.isOpen() ) {
this.mMixer.open();
this.mOpenedMixer = true;
}
this.mTargetDataLine = (TargetDataLine) this.mMixer.getLine( info );
if ( this.mAudioFormat == null ) {
this.mAudioFormat = this.mTargetDataLine.getFormat();
}
this.mTargetDataLine.open( this.mAudioFormat, this.mBufferSize );
this.mTargetDataLine.start();
}
catch (LineUnavailableException e) {
this.close();
throw new AudioException( "Error during opening the TargetDataLine" );
}
} |
fda96d90-d346-4920-82f2-14cafd52c328 | 5 | public void tick(Graphics2D g) {
for (Tank tank : GameState.getInstance().getPlayers()) {
if (tank.getNick() == null)
tank.setNick("Player");
}
if (inputReal.menu.clicked) {
inputReal.menu.clicked = false;
inputReal.releaseAll();
if (!menuTitle.isVisible()) {
menuTitle.setVisible(true);
menuBackground.setVisible(true);
GameState.getInstance().setPaused(true);
}
}
if (GameState.getInstance().isGameOver()) {
menuTitle.setVisible(true);
menuScore.setVisible(true);
menuScore.repaint();
GameState.getInstance().setRunning(false);
GameState.getInstance().setPaused(true);
GameState.getInstance().setGameOver(false);
menuBackground.setVisible(true);
}
} |
b1965abf-1f3a-456e-bb38-181a1990caa2 | 0 | public static void main(String[] args) {
List<Integer> arrayList = new ArrayList<Integer>();
arrayList.add(10);
arrayList.add(3);
arrayList.add(7);
arrayList.add(5);
System.out.println("arrayList: " + arrayList);
List<Integer> linkedList = new LinkedList<Integer>(arrayList);
System.out.println("linkedList: " + linkedList);
} |
388302c4-b95b-4d17-8814-a86a4ad30c73 | 8 | private static String initialise(Token currentToken,
int[][] expectedTokenSequences,
String[] tokenImage) {
String eol = System.getProperty("line.separator", "\n");
StringBuffer expected = new StringBuffer();
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
if (maxSize < expectedTokenSequences[i].length) {
maxSize = expectedTokenSequences[i].length;
}
for (int j = 0; j < expectedTokenSequences[i].length; j++) {
expected.append(tokenImage[expectedTokenSequences[i][j]]).append(' ');
}
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
expected.append("...");
}
expected.append(eol).append(" ");
}
String retval = "Encountered \"";
Token tok = currentToken.next;
for (int i = 0; i < maxSize; i++) {
if (i != 0) retval += " ";
if (tok.kind == 0) {
retval += tokenImage[0];
break;
}
retval += " " + tokenImage[tok.kind];
retval += " \"";
retval += add_escapes(tok.image);
retval += " \"";
tok = tok.next;
}
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
retval += "." + eol;
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + eol + " ";
} else {
retval += "Was expecting one of:" + eol + " ";
}
retval += expected.toString();
return retval;
} |
2133dfd0-9a98-4d3b-b579-7a9911933318 | 1 | public static Connection getConnection() throws SQLServerException {
if (m_connection == null) // first time
{
SQLServerDataSource ds = new SQLServerDataSource();
ds.setApplicationName("jdbc:sqlserver://");
//ds.setServerName("10.211.55.8");
ds.setServerName("localhost");
ds.setInstanceName("SQLEXPRESS");
ds.setDatabaseName("myTunesV2");
ds.setPortNumber(1433);
ds.setUser("java");
ds.setPassword("1234");
m_connection = ds.getConnection();
}
return m_connection;
} |
4fd00dd4-bd02-4aa8-b57a-f86e2aa07146 | 7 | final void A(int i, aa var_aa, int i_145_, int i_146_) {
aa_Sub3 var_aa_Sub3 = (aa_Sub3) var_aa;
int[] is = ((aa_Sub3) var_aa_Sub3).anIntArray5201;
int[] is_147_ = ((aa_Sub3) var_aa_Sub3).anIntArray5202;
int i_148_;
if (((SoftwareToolkit) this).height < i_146_ + is.length)
i_148_ = ((SoftwareToolkit) this).height - i_146_;
else
i_148_ = is.length;
int i_149_;
if (((SoftwareToolkit) this).heightOffset > i_146_) {
i_149_ = ((SoftwareToolkit) this).heightOffset - i_146_;
i_146_ = ((SoftwareToolkit) this).heightOffset;
} else
i_149_ = 0;
if (i_148_ - i_149_ > 0) {
int i_150_ = i_146_ * ((SoftwareToolkit) this).maxWidth;
for (int i_151_ = i_149_; i_151_ < i_148_; i_151_++) {
int i_152_ = i_145_ + is[i_151_];
int i_153_ = is_147_[i_151_];
if (((SoftwareToolkit) this).widthOffset > i_152_) {
i_153_ -= ((SoftwareToolkit) this).widthOffset - i_152_;
i_152_ = ((SoftwareToolkit) this).widthOffset;
}
if (((SoftwareToolkit) this).width < i_152_ + i_153_)
i_153_ = ((SoftwareToolkit) this).width - i_152_;
i_152_ += i_150_;
for (int i_154_ = -i_153_; i_154_ < 0; i_154_++)
((SoftwareToolkit) this).pixelBuffer[i_152_++] = i;
i_150_ += ((SoftwareToolkit) this).maxWidth;
}
}
} |
a8e7d814-f19f-4143-9f81-d4d71b10a278 | 8 | final public void Address() throws ParseException {
/*@bgen(jjtree) Address */
ASTAddress jjtn000 = new ASTAddress(JJTADDRESS);
boolean jjtc000 = true;
jjtree.openNodeScope(jjtn000);
try {
AddExp();
jj_consume_token(AT);
Domain();
} catch (Throwable jjte000) {
if (jjtc000) {
jjtree.clearNodeScope(jjtn000);
jjtc000 = false;
} else {
jjtree.popNode();
}
if (jjte000 instanceof RuntimeException) {
{if (true) throw (RuntimeException)jjte000;}
}
if (jjte000 instanceof ParseException) {
{if (true) throw (ParseException)jjte000;}
}
{if (true) throw (Error)jjte000;}
} finally {
if (jjtc000) {
jjtree.closeNodeScope(jjtn000, true);
}
}
} |
e0d2d1f5-6083-4578-805f-ab84714d4a1a | 1 | private PropertiesLoader(String propertiesFilePath) throws IOException {
properties = new Properties();
try(FileInputStream file = new FileInputStream(propertiesFilePath)) {
properties.load(file);
} catch (IOException e) {
String errMsg = String.format("Properties file isn't exist! %s", e.getLocalizedMessage());
logger.error(errMsg, e);
throw new IOException(errMsg);
}
setJdbcInfo();
} |
054c9ae5-8ad3-4b9e-b42d-5bdcbfe8fe54 | 6 | public static void fillItemArr(double itemArray[][], int itemNumber[], boolean bError, Scanner scan){
for(int i=0; i<4; i++){
bError = true;
System.out.print("Insert cost of item " + itemNumber[i] + " ($): ");
while(bError){
if(scan.hasNextDouble()){
itemArray[0][i] = scan.nextDouble();
}
else{
System.out.print("Value must be a data type 'double': ");
scan.next();
continue;
}
bError = false;
}
}
for(int i=0; i<4; i++){
bError = true;
System.out.print("Insert weight of item " + itemNumber[i] + " (lbs): ");
while(bError){
if(scan.hasNextDouble()){
itemArray[1][i] = scan.nextDouble();
}
else{
System.out.print("Weight must be a data type 'double': ");
scan.next();
continue;
}
bError = false;
}
}
} |
d14c68c4-d626-44f3-a639-097d7ad0f57a | 3 | public boolean equalsExpr(final Expr other) {
return (other != null) && (other instanceof InstanceOfExpr)
&& ((InstanceOfExpr) other).checkType.equals(checkType)
&& ((InstanceOfExpr) other).expr.equalsExpr(expr);
} |
7c728669-ef84-4131-b0b0-701ed11bd9a2 | 2 | public static String diffStr(String s1, String s2) {
// Create a string indicating differences
int minLen = Math.min(s1.length(), s2.length());
char diff[] = new char[minLen];
for (int j = 0; j < minLen; j++) {
if (s1.charAt(j) != s2.charAt(j)) {
diff[j] = '|';
} else diff[j] = ' ';
}
return new String(diff);
} |
e6bf668c-1bf8-4131-ae01-32b73dfb402f | 3 | public void BacaCSVAll(String filePath) throws FileNotFoundException, IOException{
File theFile = new File(filePath);
FileReader readerFile = new FileReader(theFile);
BufferedReader bufReadFile = new BufferedReader(readerFile);
String readByte;
int pencacah = 0;
System.out.println("Hasil Baca File Membaca per baris");
while ((readByte = bufReadFile.readLine()) != null) {
pencacah++;
String[] data = readByte.split(",");
// Tampilkan isi kolom 1, kolom 2, kolom 3, dsb..(sesuai kebutuhan)
System.out.print(pencacah + ". ");
for (int i=0;i<data.length;i++){
System.out.print(data[i]);
}
System.out.println();
if (pencacah==10){
break;
}
}
} |
87060742-01a2-4ee4-bfc6-9d3c94c9f648 | 0 | public The5zigModUser getUser() {
return user;
} |
e7a29628-1128-469b-9206-dff3e86f3aca | 8 | private final byte[] method2371() {
int i = 0;
for (int i_2_ = 0; i_2_ < 10; i_2_++) {
if (aClass80Array3969[i_2_] != null
&& (((Class80) aClass80Array3969[i_2_]).anInt1421
+ ((Class80) aClass80Array3969[i_2_]).anInt1407) > i)
i = (((Class80) aClass80Array3969[i_2_]).anInt1421
+ ((Class80) aClass80Array3969[i_2_]).anInt1407);
}
if (i == 0)
return new byte[0];
int i_3_ = 22050 * i / 1000;
byte[] is = new byte[i_3_];
for (int i_4_ = 0; i_4_ < 10; i_4_++) {
if (aClass80Array3969[i_4_] != null) {
int i_5_ = (((Class80) aClass80Array3969[i_4_]).anInt1421
* 22050 / 1000);
int i_6_ = (((Class80) aClass80Array3969[i_4_]).anInt1407
* 22050 / 1000);
int[] is_7_
= (aClass80Array3969[i_4_].method809
(i_5_, ((Class80) aClass80Array3969[i_4_]).anInt1421));
for (int i_8_ = 0; i_8_ < i_5_; i_8_++) {
int i_9_ = is[i_8_ + i_6_] + (is_7_[i_8_] >> 8);
if ((i_9_ + 128 & ~0xff) != 0)
i_9_ = i_9_ >> 31 ^ 0x7f;
is[i_8_ + i_6_] = (byte) i_9_;
}
}
}
return is;
} |
18c48c17-2f81-48cb-a03e-a5613c1702d6 | 0 | public void setLieu(String lieu) {
this.lieu = lieu;
} |
52518887-e975-4f54-af33-60844bcb30e3 | 9 | private static Result toResult(Object xml) throws IOException {
if (xml == null)
throw new IllegalArgumentException("no XML is given");
if (xml instanceof String) {
try {
xml = new URI((String) xml);
} catch (URISyntaxException e) {
xml = new File((String) xml);
}
}
if (xml instanceof File) {
File file = (File) xml;
return new StreamResult(file);
}
if (xml instanceof URI) {
URI uri = (URI) xml;
xml = uri.toURL();
}
if (xml instanceof URL) {
URL url = (URL) xml;
URLConnection con = url.openConnection();
con.setDoOutput(true);
con.setDoInput(false);
con.connect();
return new StreamResult(con.getOutputStream());
}
if (xml instanceof OutputStream) {
OutputStream os = (OutputStream) xml;
return new StreamResult(os);
}
if (xml instanceof Writer) {
Writer w = (Writer) xml;
return new StreamResult(w);
}
if (xml instanceof Result) {
return (Result) xml;
}
throw new IllegalArgumentException("I don't understand how to handle " + xml.getClass());
} |
a811704c-964f-4f36-9623-253377d2bdc9 | 5 | private void addAllAttributes(String shaderText) {
final String ATTRIBUTE_KEYWORD = "attribute";
int attributeStartLocation = shaderText.indexOf(ATTRIBUTE_KEYWORD);
int attribNumber = 0;
while (attributeStartLocation != -1) {
if (!(attributeStartLocation != 0
&& (Character.isWhitespace(shaderText.charAt(attributeStartLocation - 1)) || shaderText.charAt(attributeStartLocation - 1) == ';')
&& Character.isWhitespace(shaderText.charAt(attributeStartLocation + ATTRIBUTE_KEYWORD.length()))))
continue;
int begin = attributeStartLocation + ATTRIBUTE_KEYWORD.length() + 1;
int end = shaderText.indexOf(";", begin);
String attributeLine = shaderText.substring(begin, end).trim();
String attributeName = attributeLine.substring(attributeLine.indexOf(' ') + 1, attributeLine.length()).trim();
setAttribLocation(attributeName, attribNumber);
attribNumber++;
attributeStartLocation = shaderText.indexOf(ATTRIBUTE_KEYWORD, attributeStartLocation + ATTRIBUTE_KEYWORD.length());
}
} |
5da9a3a9-2d6b-4da7-9c71-db590d78da34 | 9 | @SuppressWarnings("unchecked")
private Collection<KnowledgePackage> downloadFromGuvnor(String packageId, String version) throws IOException, ClassNotFoundException{
UrlResource res=(UrlResource)ResourceFactory.newUrlResource(new URL(basePath+packageId+"/"+version));
if (enableBasicAuthentication){
res.setBasicAuthentication("enabled");
res.setUsername(username);
res.setPassword(password);
}
List<KnowledgePackage> result=new ArrayList<KnowledgePackage>();
try{
Object binaryPkg=DroolsStreamUtils.streamIn(res.getInputStream());
if (binaryPkg instanceof Collection<?>) {
result.addAll((Collection<KnowledgePackage>)binaryPkg);
}else if (binaryPkg instanceof KnowledgePackage) {
result.add((KnowledgePackage)binaryPkg);
}else if (binaryPkg instanceof org.drools.rule.Package) {
result.add(new KnowledgePackageImp((org.drools.rule.Package)binaryPkg));
}else if (binaryPkg instanceof org.drools.rule.Package[]) {
for (org.drools.rule.Package pkg:(org.drools.rule.Package[])binaryPkg) {
result.add(new KnowledgePackageImp(pkg));
}
}
}catch(IOException e){
if (failoverToEmptyRulePackage)
result.add(new KnowledgePackageImp(new Package("EMPTY")));// EMPTY PACKAGE - no rules will fire
else
throw e;
}
return result;
} |
462d3f80-8856-4195-961d-fd6dc3c83c75 | 8 | @Override
public boolean consumeFuel(int amount)
{
final List<Item> fuel=getFuel();
boolean didSomething =false;
for(final Item I : fuel)
{
if((I instanceof RawMaterial)
&&(!I.amDestroyed())
&&CMParms.contains(this.getConsumedFuelTypes(), ((RawMaterial)I).material()))
{
amount-=CMLib.materials().destroyResourcesAmt(fuel, amount, ((RawMaterial)I).material(),this);
if(!I.amDestroyed()) // why is this necessary
I.recoverPhyStats();
didSomething=true;
if(amount<=0)
break;
}
}
if(amount>0)
engineShutdown();
if(didSomething)
clearFuelCache();
return amount<=0;
} |
5b3a1392-9abe-4500-a471-8d8e40132b67 | 5 | private boolean isExcluded(String name) {
return name.startsWith(ClassMetaobject.methodPrefix)
|| name.equals(classobjectAccessor)
|| name.equals(metaobjectSetter)
|| name.equals(metaobjectGetter)
|| name.startsWith(readPrefix)
|| name.startsWith(writePrefix);
} |
db0d6ef2-f198-45db-85b7-10eafa4682a2 | 9 | private boolean r_Step_4() {
int among_var;
int v_1;
// (, line 140
// [, line 141
ket = cursor;
// substring, line 141
among_var = find_among_b(a_7, 18);
if (among_var == 0)
{
return false;
}
// ], line 141
bra = cursor;
// call R2, line 141
if (!r_R2())
{
return false;
}
switch(among_var) {
case 0:
return false;
case 1:
// (, line 144
// delete, line 144
slice_del();
break;
case 2:
// (, line 145
// or, line 145
lab0: do {
v_1 = limit - cursor;
lab1: do {
// literal, line 145
if (!(eq_s_b(1, "s")))
{
break lab1;
}
break lab0;
} while (false);
cursor = limit - v_1;
// literal, line 145
if (!(eq_s_b(1, "t")))
{
return false;
}
} while (false);
// delete, line 145
slice_del();
break;
}
return true;
} |
3520a565-38a8-4661-86bb-3ab260fdd125 | 1 | public static void main(String[] args) {
try {
TextComponent text = (TextComponent) new BookReader().read("text.txt");
System.out.println(new ComponentConverter().componentToString(text));
System.out.print("Sentencis with the same words: ");
System.out.println(new SameWordsFinder(text).getSentenceCount());
new BookWriter().write(text, "out.txt");
} catch (BookException e) {
LOG.fatal("Fatal", e);
}
} |
e4a429fa-14c5-43be-b839-3ad532a163ad | 7 | public int countGenerators(String[] fragment, int W, int i0, int j0){
int n = fragment.length;
int m = fragment[0].length();
int result=0;
for(int l=1; l<=W; l++){
char[] string = new char[l];
boolean valid = true;
int filledCount = 0;
for(int i=0; i<n; i++){
if(!valid) break;
for(int j=0; j<m; j++){
int index = (W*i+j)%l;
if(string[index]==0){
string[index]=fragment[i].charAt(j);
filledCount++;
} else
if(string[index]!=fragment[i].charAt(j)){
valid = false;
break;
}
}
}
if(!valid) continue;
result = (result+pow(26, l-filledCount))%MOD;
}
return result;
} |
071af8a3-08b6-4f06-899b-b30e22422418 | 2 | protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
String msj_error = "Error al exportar consulta";
HttpSession sesion = request.getSession(true);
String tipo_sesion = (String) sesion.getAttribute("identidad");
String genera = request.getParameter("genera");
if (genera == null) {
try {
creaXLS(response);
} catch (ServletException | IOException e) {
response.sendRedirect(tipo_sesion + ".jsp?mensaje=" + URLEncoder.encode(msj_error, "UTF-8") + "&exito=false");
}
} else {
marca = request.getParameter("marca");
numero = request.getParameter("numeroSerie");
familia = request.getParameter("familia");
ubicacion = request.getParameter("ubicacion");
responsable = request.getParameter("responsable");
tipoEquipo = request.getParameter("tipoEquipo");
departamento = request.getParameter("departamento");
fechai = request.getParameter("fechaI");
fechaf = request.getParameter("fechaF");
estado = request.getParameter("estado");
}
} |
922b9ee8-c6d1-4088-8a91-150cc9bb973e | 9 | private int fillbuf() throws IOException {
if (markpos == -1 || (pos - markpos >= marklimit)) {
/* Mark position not set or exceeded readlimit */
int result = in.read(buf);
if (result > 0) {
markpos = -1;
pos = 0;
count = result == -1 ? 0 : result;
}
return result;
}
if (markpos == 0 && marklimit > buf.length) {
/* Increase buffer size to accomodate the readlimit */
int newLength = buf.length * 2;
if (newLength > marklimit) {
newLength = marklimit;
}
byte[] newbuf = new byte[newLength];
System.arraycopy(buf, 0, newbuf, 0, buf.length);
buf = newbuf;
} else if (markpos > 0) {
System.arraycopy(buf, markpos, buf, 0, buf.length - markpos);
}
/* Set the new position and mark position */
pos -= markpos;
count = markpos = 0;
int bytesread = in.read(buf, pos, buf.length - pos);
count = bytesread <= 0 ? pos : pos + bytesread;
return bytesread;
} |
dbec7c4c-fe28-4d5a-a87d-06fc8bfe8f66 | 0 | public Point getInitialResizePoint() {
return initialResizePoint;
} |
49b922f4-1159-4bde-80e9-0f26a6259874 | 8 | private String getMimeType(String request) {
if(request.endsWith(".html") || request.endsWith(".htm"))
return "text/html";
else if(request.endsWith(".css"))
return "text/css";
else if(request.endsWith(".js"))
return "text/javascript";
else if(request.endsWith(".jpg") || request.endsWith(".jpeg"))
return "image/jpeg";
else if(request.endsWith(".png"))
return "image/png";
else if(request.endsWith(".ico"))
return "image/icon";
else
return "application/octet-stream";
} |
41495a7a-1b5c-4d79-8178-2abe4d1c61ad | 5 | private void pop(char c) throws JSONException {
if (this.top <= 0) {
throw new JSONException("Nesting error.");
}
char m = this.stack[this.top - 1] == null ? 'a' : 'k';
if (m != c) {
throw new JSONException("Nesting error.");
}
this.top -= 1;
this.mode = this.top == 0
? 'd'
: this.stack[this.top - 1] == null
? 'a'
: 'k';
} |
b5520b65-a2d6-4f6b-8bae-aae8bf1d9714 | 2 | public static int sum(List<? extends Number> numbers){
int sum = 0;
for(Number number: numbers){
sum += number.doubleValue();
}
return sum;
} |
8869bc9a-e790-4e0f-b1b0-d86f2e29313e | 5 | public String getFlagStr(){
if (this.getFlag()==1) return "SYN";
if (this.getFlag()==2) return "FIN";
if (this.getFlag()==3) return "PSH";
if (this.getFlag()==4) return "ACK";
if (this.getFlag()==5) return "SYN_ACK";
return "";
} |
e240c364-ed7c-4541-b44d-eb8f60997123 | 5 | @Override
public void run() {
if(inputFile.length() < inputSize/BYTESIZE) {
System.out.println("Input too short, check inputfile");
return;
}
byte[] bytesRead = getBytesFromFile();
BitString input = byteArrayToBitSet(bytesRead);
if (mode.equals(Driver.EVAL_FAIRPLAY_IA32)) {
input = input.getIA32BitString();
} else if (mode.equals(Driver.EVAL_FAIRPLAY_MIRRORED)) {
input = input.getMirroredBitString();
} else if (mode.equals(Driver.EVAL_FAIRPLAY_REVERSED) ||
mode.equals(Driver.EVAL_SPACL)) {
input = input.getReverseOrder();
}
// The result returned is in big endian, the evaluator flips the
// ouput before returning
BitString output = evalCircuit(layersOfGates, input);
writeCircuitOutput(output);
} |
8035c9f4-8d65-40e2-8903-2c52bed09a2e | 5 | private boolean moveable(int destx, int desty) {
if (destx<0||desty<0) {return false;}
if (destx>=Game.map.width||desty>=Game.map.height) {return false;}
if (Pathed(destx,desty)) {return true;}
return false;
} |
2bded864-e928-4ffa-b4ea-a9a4cd26d156 | 4 | public void deleteCustomer(int id) {
Connection con = null;
Statement stmt = null;
try {
DBconnection dbCon = new DBconnection();
Class.forName(dbCon.getJDBC_DRIVER());
con = DriverManager.getConnection(dbCon.getDATABASE_URL(),
dbCon.getDB_USERNAME(), dbCon.getDB_PASSWORD());
stmt = con.createStatement();
stmt.execute("Delete From customer Where cst_id = " + String.valueOf(id));
} catch (SQLException | ClassNotFoundException ex) {
System.err.println("Caught Exception: " + ex.getMessage());
} finally {
try {
if (stmt != null) {
stmt.close();
}
if (con != null) {
con.close();
}
} catch (SQLException ex) {
System.err.println("Caught Exception: " + ex.getMessage());
}
}
} |
176fc95e-9dcd-4a4e-9c42-c10cbe8f6b5c | 0 | public String toString(String input) {
return _base+"^("+input+")";
} |
04d28db2-3089-41fe-a7c7-aad28df5d1c0 | 4 | public static String deleteWhitespace(String str)
{
if (isEmpty(str))
{
return str;
}
int sz = str.length();
char[] chs = new char[sz];
int count = 0;
for (int i = 0; i < sz; i++)
{
if (!Character.isWhitespace(str.charAt(i)))
{
chs[count++] = str.charAt(i);
}
}
if (count == sz)
{
return str;
}
return new String(chs, 0, count);
} |
b7e58776-0249-499b-9b3b-eca85ab1f381 | 0 | public void testLigne(int lig, int col, String nom) {// a renommer en
// lecture
System.out.println("lig: " + lig + " col:" + col + " nom: " + nom);
setChanged();
notifyObservers();
} |
6c463601-ea07-4489-be39-71146197be0a | 0 | public static void main(String[] args) {
DeleteAll de = new DeleteAll();
de.delAll1(new File("D:/aaa"));
// de.delAll( "D:/aaa/sdagsda");
} |
703c8b19-c5bd-4ebd-96cd-7e691ecafc66 | 1 | @Override
public void notifyObservers() {
ModelChangedEventArgs args = new ModelChangedEventArgs(
this.getChildren());
for (IObserver observer : this.observers) {
observer.updateObserver(args);
}
} |
13ef1c5a-5d9c-42dc-9078-40255d267a5f | 8 | public static int evaluate(String [] expr) {
LinkedList<String> stack = new LinkedList<>();
String operators = "+-*/";
for(String symbol : expr ) {
if(!operators.contains(symbol)) {
stack.push(symbol);
} else {
if(stack.size() >=2) {
int operand1 = Integer.parseInt(stack.pop());
int operand2 = Integer.parseInt(stack.pop());
int operatorIndex = operators.indexOf(symbol);
switch(operatorIndex) {
case 0 : stack.push(String.valueOf(operand1 + operand2));
break;
case 1 : stack.push(String.valueOf(operand1 - operand2));
break;
case 2 : stack.push(String.valueOf(operand1 * operand2));
break;
case 3 : stack.push(String.valueOf(operand1 / operand2));
break;
default: break;
}
}
}
}
return stack.size() == 1 ? Integer.parseInt(stack.pop()): -1;
} |
f7eaea0f-9e40-4f8f-8ce4-45ae52773988 | 5 | @Override
public void run()
{
String input;
StringTokenizer idata;
int i, j;
int counter = 0;
input = Main.ReadLn(255);
while ((input != null) && !input.equals(""))
{
idata = new StringTokenizer(input);
i = Integer.parseInt(idata.nextToken());
j = Integer.parseInt(idata.nextToken());
/* Loop through and run the algorithm on each of the integers between these numbers */
int maxCycleLength = 0;
for (int x = i; x <= j; x++)
{
/* Get the Max Cycle Length */
int cl = this.getCycleLength(x);
if (cl > maxCycleLength)
{
maxCycleLength = cl;
}
}
if (counter != 0)
{
System.out.print("\n");
}
counter++;
System.out.print(input.concat(" " + maxCycleLength));
input = Main.ReadLn(255);
}
System.exit(0);
} |
b3d0f579-010e-4637-9359-64ce4f8af10e | 3 | public void toggleRowOpenState() {
boolean first = true;
boolean open = true;
for (int i = 0; i < mRows.size(); i++) {
Row row = getRowAtIndex(i);
if (row.canHaveChildren()) {
if (first) {
open = !row.isOpen();
first = false;
}
row.setOpen(open);
}
}
} |
981ff82a-5a1a-4cd2-a924-4ac1015c0032 | 4 | public JSONWriter key(String string) throws JSONException {
if (string == null) {
throw new JSONException("Null key.");
}
if (this.mode == 'k') {
try {
this.stack[this.top - 1].putOnce(string, Boolean.TRUE);
if (this.comma) {
this.writer.write(',');
}
this.writer.write(JSONObject.quote(string));
this.writer.write(':');
this.comma = false;
this.mode = 'o';
return this;
} catch (IOException e) {
throw new JSONException(e);
}
}
throw new JSONException("Misplaced key.");
} |
817a52ed-d624-44cc-abf8-9b3a9bf7fcf7 | 1 | public void updateUniforms(Matrix4f worldMatrix, Matrix4f projectedMatrix, Material material)
{
if(material.getTexture() != null)
material.getTexture().bind();
else
RenderUtil.unbindTextures();
setUniform("transform", projectedMatrix);
setUniform("color", material.getColor());
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.