method_id stringlengths 36 36 | cyclomatic_complexity int32 0 9 | method_text stringlengths 14 410k |
|---|---|---|
6de30785-8aaf-4018-b9ab-0a3e90f27fc5 | 3 | private static void sort(int[] array) {
// TODO Auto-generated method stub
for(int i = 0; i < array.length - 1; i++){
for(int k = 0; k < array.length - 1 ; k++){
int temp;
if(array[k] > array[k+1]){
temp = array[k];
array[k] = array[k+1];
array[k+1]=temp;
}
}
}
} |
8fba8458-2f84-4ee3-a6fa-f8c40327a416 | 9 | protected ArrayList<Placement> densityMapping(Field[][] map, int c) {
shootDensity.clear();
for (int y = 0; y < map.length; ++y) {
for (int x = 0; x < map[y].length - shipValue + 1; ++x) {
int tmp = 0;
for (int z = 0; z < shipValue; ++z) {
//tmp = tmp + map[x + z][y].getOppShotTrend();
int tmp2 = map[x + z][y].getOppShotTrend();
if (tmp2 > tmp) {
tmp = tmp2;
}
}
Placement temp = new Placement(new Position(x, y), false, tmp);
shootDensity.add(temp);
}
}
for (int y = 0; y < map.length - shipValue; ++y) {
for (int x = 0; x < map[y].length; ++x) {
int tmp = 0;
for (int z = 0; z < shipValue; ++z) {
//tmp = tmp + map[x][y + z].getOppShotTrend();
int tmp2 = map[x][y + z].getOppShotTrend();
if (tmp2 > tmp) {
tmp = tmp2;
}
}
Placement temp = new Placement(new Position(x, y), true, tmp);
shootDensity.add(temp);
}
}
if (c > 5) {
Collections.sort(shootDensity);
} else {
Collections.shuffle(shootDensity);
}
return shootDensity;
} |
98bcd902-f9f3-41e6-8092-98c7207bfd1c | 6 | public Map<String, Integer> splitAndCount() throws EmptyLineException {
String delims = ", :.-=+/*";
for (int i=0; i<arrayOfStrings.size(); i++){
String splitString = arrayOfStrings.get(i);
if (splitString.isEmpty()) {
throw new EmptyLineException("Empty line");
}
StringTokenizer st = new StringTokenizer(splitString, delims);
while (st.hasMoreTokens()) {
splitStr.add((String) st.nextElement());
}
}
String tempStr;
for (int i = 0; i < splitStr.size(); i++) {
int count = 1;
tempStr = splitStr.get(i);
for (int l = i + 1; l < splitStr.size(); l++) {
if (splitStr.get(l).equalsIgnoreCase(tempStr)) {
count++;
splitStr.remove(l);
}
}
mapOfCounts.put(tempStr, count);
/*for (String str : mapOfCounts.keySet()) {
System.out.println(str);
System.out.println(mapOfCounts.get(str));
}*/
}
return mapOfCounts;
} |
23d6adf9-e1fc-40a8-aa3b-c132a68b431a | 8 | private boolean r_tidy_up() {
int among_var;
// (, line 183
// [, line 184
ket = cursor;
// substring, line 184
among_var = find_among_b(a_7, 4);
if (among_var == 0)
{
return false;
}
// ], line 184
bra = cursor;
switch(among_var) {
case 0:
return false;
case 1:
// (, line 188
// delete, line 188
slice_del();
// [, line 189
ket = cursor;
// literal, line 189
if (!(eq_s_b(1, "\u043D")))
{
return false;
}
// ], line 189
bra = cursor;
// literal, line 189
if (!(eq_s_b(1, "\u043D")))
{
return false;
}
// delete, line 189
slice_del();
break;
case 2:
// (, line 192
// literal, line 192
if (!(eq_s_b(1, "\u043D")))
{
return false;
}
// delete, line 192
slice_del();
break;
case 3:
// (, line 194
// delete, line 194
slice_del();
break;
}
return true;
} |
3c46026d-2c1a-4c86-96f0-027b995953e6 | 8 | public Sudoku(boolean autoPossBasic, boolean autoPossAdvanced,
boolean autoFillBasic, boolean autoFillAdvanced, boolean possAsNum,
boolean initialPoss, int initNumbers, int size,
final MouseListenerMethod m, int difficulty) {
super(new GridBagLayout());
this.size = size;
this.selectedRow = size*size / 2;
this.selectedColumn = size*size / 2;
this.errorRow = size*size / 2;
this.errorColumn = size*size / 2;
this.possAsNum = possAsNum;
if (difficulty == Grid.DIFFICULTY_NONE) {
this.grid = Grid.generate(autoPossBasic, autoPossAdvanced,
autoFillBasic, autoFillAdvanced, initialPoss,
initNumbers, size);
} else {
this.grid = Grid.uniqueGen(autoPossBasic, autoPossAdvanced,
autoFillBasic, autoFillAdvanced, initialPoss,
difficulty, size);
}
this.label = new JLabel[size*size][size*size];
this.containsValue = new boolean[size*size][size*size];
GridBagConstraints c = new GridBagConstraints();
for (int i = 0; i < size*size; i++) {
for (int j = 0; j < size*size; j++) {
label[i][j] = new JLabel();
label[i][j].setPreferredSize(new Dimension(50, 50));
label[i][j].setOpaque(true);
label[i][j].setBackground(new Color(255, 255, 191));
label[i][j].setHorizontalAlignment(JLabel.CENTER);
if (grid.isEditable(i, j)) {
label[i][j].setFont(FONT_POSS);
label[i][j].setForeground(COLOR_POSS);
} else {
label[i][j].setForeground(COLOR_UNEDITABLE);
label[i][j].setFont(FONT_UNEDITABLE);
}
int top = i > 0 && i % size == 0? 2 : 0;
int left = j > 0 && j % size == 0? 2 : 0;
label[i][j].setBorder(new CompoundBorder(
new MatteBorder(top, left, 0, 0, Color.black),
new CompoundBorder(new LineBorder(Color.black, 1),
new EmptyBorder(1, 1, 1, 1))));
final int fi = i, fj = j;
label[i][j].addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
select(fi, fj);
m.exec(e);
}
});
c.gridx = j;
c.gridy = i;
add(label[i][j], c);
containsValue[i][j] = grid.value(i, j) != 0;
}
}
select(selectedRow, selectedColumn);
refresh();
} |
a64cfe54-9216-424b-a87e-f82d92d4b29f | 8 | @Override
public int[] find(final String[] criteria) throws RecordNotFoundException {
final List<Integer> results = new ArrayList<Integer>();
for (int n = 0; n < this.contractors.size(); n++) {
if (!this.isRecordDeleted(n)) {
this.lock(n);
boolean match = true;
for (int i = 0; i < criteria.length; i++) {
if (criteria[i] != null) {
String field = this.contractors.get(n)[i];
if (field != null) {
field = field.toLowerCase();
final String critField = criteria[i].toLowerCase();
if (!field.contains(critField)) {
match = false;
}
} else {
match = false;
}
}
}
if (match) {
results.add(n);
}
this.unlock(n);
}
}
final int[] intResults = new int[results.size()];
for (int i = 0; i < results.size(); i++) {
intResults[i] = results.get(i);
}
return intResults;
} |
bb4d5c31-e4d7-4cd7-adc3-040dba0d711f | 2 | @Override
public void initialize(Vertex start) {
initializeSingleSource(start);
for (int i = 0; i < vertices.getSize(); i++) {
heap.insert(vertices.get(i));
}
for (int i = 0; i < edges.getSize(); i++) {
edges.get(i).setVisited(false);
}
} |
576d4de1-32fb-4855-a787-485005ffcf44 | 6 | public void checkForRightInput(int rs, int cs) {
boolean isTooBig = checkForTooBigInput(rs, cs);
if(isTooBig) {
showTooBigInputError();
}
if(rs > 0 && cs > 0 && !isTooBig) {
model = new GameSimulator(rs, cs);
createNewWindow();
}
if(rs == 0 || cs == 0) {
showCharacterInputError();
}
} |
e8ca90b8-b60d-4ef5-a7f9-cfd410204aca | 3 | @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
final POSTerminal other = (POSTerminal) obj;
return Objects.equals(this.terminalID, other.terminalID);
} |
b12bbe79-9392-4a81-b04f-fef1bab6f570 | 4 | public boolean newLibrary( Class libraryClass )
throws SoundSystemException
{
initialized( SET, false );
CommandQueue( new CommandObject( CommandObject.NEW_LIBRARY,
libraryClass ) );
commandThread.interrupt();
for( int x = 0; (!initialized( GET, XXX )) && (x < 100); x++ )
{
snooze( 400 );
commandThread.interrupt();
}
if( !initialized( GET, XXX ) )
{
SoundSystemException sse = new SoundSystemException(
className +
" did not load after 30 seconds.",
SoundSystemException.LIBRARY_NULL );
lastException( SET, sse );
throw sse;
}
else
{
SoundSystemException sse = lastException( GET, null );
if( sse != null )
throw sse;
}
return true;
} |
4457c2e6-e82d-4f21-97e1-4fa0fcf9023b | 7 | public static boolean adjoinTaxonomyNodeIntervalP(TaxonomyNode node, Interval interval) {
{ Cons intervalstoremove = Stella.NIL;
{ Interval renamed_Int = null;
Cons iter000 = node.intervals;
for (;!(iter000 == Stella.NIL); iter000 = iter000.rest) {
renamed_Int = ((Interval)(iter000.value));
if (renamed_Int.lowerBound < interval.lowerBound) {
if (renamed_Int.upperBound >= interval.upperBound) {
return (false);
}
else {
if (interval.lowerBound <= (renamed_Int.upperBound + 1)) {
TaxonomyNode.removeTaxonomyNodeInterval(node, renamed_Int);
TaxonomyNode.adjoinTaxonomyNodeIntervalP(node, Interval.mergeIntervals(renamed_Int, interval));
return (true);
}
}
}
else {
if (interval.upperBound >= renamed_Int.upperBound) {
intervalstoremove = Cons.cons(renamed_Int, intervalstoremove);
}
else {
if (renamed_Int.lowerBound <= (interval.upperBound + 1)) {
TaxonomyNode.removeTaxonomyNodeInterval(node, renamed_Int);
TaxonomyNode.adjoinTaxonomyNodeIntervalP(node, Interval.mergeIntervals(interval, renamed_Int));
return (true);
}
}
}
}
}
{ Stella_Object renamed_Int = null;
Cons iter001 = intervalstoremove;
for (;!(iter001 == Stella.NIL); iter001 = iter001.rest) {
renamed_Int = iter001.value;
TaxonomyNode.removeTaxonomyNodeInterval(node, ((Interval)(renamed_Int)));
}
}
TaxonomyNode.addTaxonomyNodeInterval(node, interval);
return (true);
}
} |
8694ec85-26c6-434d-8f4b-b36094c6181a | 0 | @Basic
@Column(name = "zip")
public String getZip() {
return zip;
} |
4a8c2619-643d-4bbb-ab7b-deb9c7e3ef82 | 9 | private void dfs(int x,int y){
if(dist<0) return;
grid[y][x] = 1;
for (int i=-dist;i<=dist;i++){
for(int j=Math.abs(i)-dist;j<=dist-Math.abs(i);j++){
int newx = x+i;
int newy = y+j;
if(newx>=0&&newx<width&&newy>=0&&newy<height&&field[newy].charAt(newx)=='v'&&grid[newy][newx]==0){
dfs(newx,newy);
}
}
}
} |
c279b67a-d903-4569-830a-14d35e8c85c9 | 0 | public JuliaPanelDouble(double a, double b)
{
left = -2;
right = 2;
top = -1;
bottom = 1;
cA = a;
cB = b;
} |
fc296c72-87f4-49b1-af2f-7ac1f5b102c5 | 4 | public int getInt(int index, int length) {
// User input.
List<String> words = this.getParser().getInput();
if (!words.isEmpty()) {
try {
index = Integer.parseInt(words.get(0));
// Index out of bounds.
if (index >= 0 && index < length) {
return index;
}
} catch (NumberFormatException e) {
}
}
System.out.println("Incorrect number.");
return this.getInt(index, length);
} |
625e4d73-5f1d-432e-8c26-1b4178f986a4 | 5 | public void parseEncoding(PDFObject encoding) throws IOException {
differences = new HashMap<Character,String>();
// figure out the base encoding, if one exists
PDFObject baseEncObj = encoding.getDictRef("BaseEncoding");
if (baseEncObj != null) {
baseEncoding = getBaseEncoding(baseEncObj.getStringValue());
}
// parse the differences array
PDFObject diffArrayObj = encoding.getDictRef("Differences");
if (diffArrayObj != null) {
PDFObject[] diffArray = diffArrayObj.getArray();
int curPosition = -1;
for (int i = 0; i < diffArray.length; i++) {
if (diffArray[i].getType() == PDFObject.NUMBER) {
curPosition = diffArray[i].getIntValue();
} else if (diffArray[i].getType() == PDFObject.NAME) {
Character key = new Character((char) curPosition);
differences.put(key, diffArray[i].getStringValue());
curPosition++;
} else {
throw new IllegalArgumentException("Unexpected type in diff array: " + diffArray[i]);
}
}
}
} |
5530d005-eaa7-496d-92fc-dd4de7f416a4 | 4 | public void testCaseSensitiveMetaData() {
DataSet ds;
final String cols = "COLUMN1,column2,Column3\r\n value1,value2,value3";
Parser p = DefaultParserFactory.getInstance().newDelimitedParser(new StringReader(cols), ',', FPConstants.NO_QUALIFIER);
// check that column names are case sensitive
p.setColumnNamesCaseSensitive(true);
ds = p.parse();
ds.next();
try {
ds.getString("COLUMN2");
fail("Column was mapped as 'column2' and lookup was 'COLUMN2'...should fail with case sensitivity turned on");
} catch (final NoSuchElementException e) {
// this should happen since we are matching case
}
// check that column names are NOT case sensitive
p = DefaultParserFactory.getInstance().newDelimitedParser(new StringReader(cols), ',', FPConstants.NO_QUALIFIER);
p.setColumnNamesCaseSensitive(false);
ds = p.parse();
ds.next();
try {
ds.getString("COLUMN2");
} catch (final NoSuchElementException e) {
fail("Column was mapped as 'column2' and lookup was 'COLUMN2'...should NOT fail with case sensitivity turned OFF");
}
// re-test the buffered reader
p = BuffReaderParseFactory.getInstance().newDelimitedParser(new StringReader(cols), ',', FPConstants.NO_QUALIFIER);
// check that column names are case sensitive
p.setColumnNamesCaseSensitive(true);
ds = p.parse();
ds.next();
try {
ds.getString("COLUMN2");
fail("Column was mapped as 'column2' and lookup was 'COLUMN2'...should fail with case sensitivity turned on");
} catch (final NoSuchElementException e) {
// this should happen since we are matching case
}
// check that column names are NOT case sensitive
p = DefaultParserFactory.getInstance().newDelimitedParser(new StringReader(cols), ',', FPConstants.NO_QUALIFIER);
p.setColumnNamesCaseSensitive(false);
ds = p.parse();
ds.next();
try {
ds.getString("COLUMN2");
} catch (final NoSuchElementException e) {
fail("Column was mapped as 'column2' and lookup was 'COLUMN2'...should NOT fail with case sensitivity turned OFF");
}
} |
555ea372-6ea0-4450-8c26-1e19b2fb24e2 | 9 | public void paint(Graphics g, Shape a) {
Color oldColor = g.getColor();
fBounds = a.getBounds();
int border = getBorder();
int x = fBounds.x + border + getSpace(X_AXIS);
int y = fBounds.y + border + getSpace(Y_AXIS);
int width = fWidth;
int height = fHeight;
int sel = getSelectionState();
if( ! hasPixels(this) ) {
g.setColor(Color.lightGray);
g.drawRect(x,y,width-1,height-1);
g.setColor(oldColor);
loadIcons();
Icon icon = fImage==null ?sMissingImageIcon :sPendingImageIcon;
if( icon != null )
icon.paintIcon(getContainer(), g, x, y);
}
if( fImage != null ) {
g.drawImage(fImage,x, y,width,height,this);
}
Color bc = getBorderColor();
if( sel == 2 ) {
int delta = 2-border;
if( delta > 0 ) {
x += delta;
y += delta;
width -= delta<<1;
height -= delta<<1;
border = 2;
}
bc = null;
g.setColor(Color.black);
g.fillRect(x+width-5,y+height-5,5,5);
}
if( border > 0 ) {
if( bc != null ) g.setColor(bc);
for( int i=1; i<=border; i++ )
g.drawRect(x-i, y-i, width-1+i+i, height-1+i+i);
g.setColor(oldColor);
}
} |
ef5ab2b8-7e3e-4b60-9a3b-c50df589044b | 5 | @Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof SiteBoundaryDataset)) {
return false;
}
SiteBoundaryDataset other = (SiteBoundaryDataset) object;
if ((this.datasetKey == null && other.datasetKey != null) || (this.datasetKey != null && !this.datasetKey.equals(other.datasetKey))) {
return false;
}
return true;
} |
c0b83685-ef95-4787-9e28-98d4400c8f85 | 7 | public static Locale toLocale(Object value) throws ConversionException {
if (value instanceof Locale) {
return (Locale)value;
} else if (value instanceof String) {
List elements = split((String)value, '_');
int size = elements.size();
if (size >= 1 &&
(((String)elements.get(0)).length() == 2 || ((String)elements.get(0)).length() ==
0)) {
String language = (String)elements.get(0);
String country = (String)((size >= 2) ? elements.get(1) : "");
String variant = (String)((size >= 3) ? elements.get(2) : "");
return new Locale(language, country, variant);
} else {
throw new ConversionException("The value " + value +
" can't be converted to a Locale");
}
} else {
throw new ConversionException("The value " + value +
" can't be converted to a Locale");
}
} |
58833fa1-4514-43f7-bf35-4d8199b1850c | 0 | public Date getBookingDate() {
return bookingDate;
} |
799127dd-4563-4397-be55-87090e618feb | 7 | private void resize() {
width = getSkinnable().getWidth();
height = getSkinnable().getHeight();
size = width < height ? width : height;
if (width > 0 && height > 0) {
if (aspectRatio * width > height) {
width = 1 / (aspectRatio / height);
} else if (1 / (aspectRatio / height) > width) {
height = aspectRatio * width;
}
font = Font.font("Open Sans", FontWeight.BOLD, FontPosture.REGULAR, height * 0.5);
background.setPrefSize(width, height);
symbol.setPrefSize(height * 0.59375 * getSkinnable().getSymbolType().WIDTH_FACTOR, height * 0.59375 * getSkinnable().getSymbolType().HEIGHT_FACTOR);
symbol.relocate(height * 0.15 + (height * 0.59375 - height * 0.59375 * getSkinnable().getSymbolType().WIDTH_FACTOR) * 0.5,
height * 0.18 + (height * 0.59375 - height * 0.59375 * getSkinnable().getSymbolType().HEIGHT_FACTOR) * 0.5);
text.setFont(font);
text.setVisible(!getSkinnable().getText().isEmpty() && SymbolType.NONE == getSkinnable().getSymbolType());
text.setPrefSize(height * 0.59375, height * 0.59375);
text.relocate(height * 0.125, height * 0.15);
thumb.setPrefSize((height * 0.75), (height * 0.75));
thumb.setTranslateX(getSkinnable().isSelected() ? height * 1.625 : height * 0.875);
thumb.setTranslateY(height * 0.125);
moveToDeselected.setFromX(height * 1.625);
moveToDeselected.setToX(height * 0.875);
moveToSelected.setFromX(height * 0.875);
moveToSelected.setToX(height * 1.625);
}
} |
3ee43097-f6f6-4ced-9648-61030c1ad9ff | 0 | static public double[] getMarker(int x, int y)
{
double lat = latitude - yToMap[zoomIndex]*y + imageSizeH/2*yToMap[zoomIndex];
double lon = longtitude + xToMap[zoomIndex]*x - imageSizeW/2*xToMap[zoomIndex];
double [] coords = {lat, lon};
return coords;
} |
8b5311e4-d285-4346-aacf-4c50f531c09d | 2 | @Override
public void bougerPierre(int x, int y) {
if (donjon.getPosition(x, y).estVide()) {
e = donjon.getElementMobile(x, y);
if (e == null) {
setX(x);
setY(y);
}
}
} |
64f98586-b7b7-4865-adc7-b6360ec9d46c | 5 | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
String url = "jdbc:mysql://db4free.net:3306/";
String driver = "com.mysql.jdbc.Driver";
String userName = "komunikator";
String password = "pawel01";
String login1 = "";
String password1 = "";
String loginTB = jTextField1.getText();
String passwordTB = jTextField2.getText();
ResultSet resultSet = null;
Statement statement = null;
boolean authentication = false;
try {
Class.forName(driver).newInstance();
Connection conn = DriverManager.getConnection(url, userName,
password);
jLabel1.setText("Connected");
statement = conn.createStatement();
resultSet = statement
.executeQuery("select * from komunikatorpsz.User");
while (resultSet.next()) {
login1 = resultSet.getString("Login");
password1 = resultSet.getString("Password");
if (login1.equals(loginTB))
if (password1.equals(passwordTB)) {
authentication = true;
break;
} else
authentication = false;
}
if (authentication)
{
jLabel1.setText("Logged In");
this.show(false);
mainwindow main = new mainwindow(loginTB);
main.show(true);
}
else
jLabel1.setText("Wrong Login or Password");
conn.close();
} catch (Exception e) {
jLabel1.setText("Not Connected");
e.printStackTrace();
}
// TODO add your handling code here:
} |
5ab137b6-bf2b-4f21-824e-53c9b6ae4884 | 5 | @Override
public ShadeRec clone() {
ShadeRec sr = new ShadeRec(world);
sr.hitAnObject = hitAnObject;
sr.material = material == null ? null : material.clone();
sr.worldHitPoint = worldHitPoint == null ? null : worldHitPoint.clone();
sr.ray = ray == null ? null : new Ray(ray.getOrigin(), ray.getDirection());
sr.depth = depth;
sr.dir = dir == null ? null : dir.clone();
sr.normal = normal == null ? null : normal.clone();
return sr;
} |
0aa892f4-22f3-489a-abc8-042edf52d527 | 5 | private int findHeaderEnd(final byte[] buf, int rlen) {
int splitbyte = 0;
while (splitbyte + 3 < rlen) {
if (buf[splitbyte] == '\r' && buf[splitbyte + 1] == '\n' && buf[splitbyte + 2] == '\r' && buf[splitbyte + 3] == '\n') {
return splitbyte + 4;
}
splitbyte++;
}
return 0;
} |
1fc00d32-af92-4bd9-b728-e67d8aadffc3 | 2 | public void hauptPhase() {
aktuellerSpieler = spieler1;
System.out.println("hauptphase");
while(laenderGraph.getAnzahlLaender(spieler1.getFraktion()) != 0 && laenderGraph.getAnzahlLaender(spieler2.getFraktion()) != 0) {
int verfuegbareEinheiten = ermittleVerstaerkung(aktuellerSpieler);
aktuellerSpieler.einheitenSetzen(verfuegbareEinheiten, laenderGraph);
aktuellerSpieler.makeMove(laenderGraph);
wechsleSpieler(aktuellerSpieler);
aktuellerSpieler.zugZuende = false;
frame.repaint();
}
} |
21f3339e-0abd-447a-a739-6526c176f932 | 0 | public void loadModule(Module module){
module.setModuleManager(this);
module.onStart();
modules.add(module);
DebugUtils.info("Module " + module.getName() + " loaded");
} |
fbc1554c-e012-4c63-99e8-71c5648e3dcc | 9 | public boolean canLoot(MapleCharacter player, int itemid) {
if (player.isAdmin()) {
return true;
}
int i = 0;
if (!player.isGenin() && Items.isSummonBag(itemid)) {
return false;
}
switch (itemid) {
case 4000241:
i = 1;
break;
case 4000332:
i = 2;
break;
case 4000131:
i = 3;
break;
case 4001063:
i = 4;
break;
case 4000415:
i = 5;
break;
}
if (i == 0) {
return true;
} else {
return player.getVillage() == (Village.getVillageByItem(itemid));
}
} |
23cd40c1-c58e-46b7-8802-3073ee38b26d | 8 | public void actionPerformed(ActionEvent __event) {
try {
Object OBJ = __event.getSource();
Object read;
File file;
if (OBJ == _save || OBJ == _saveb) {
file = selectFile(_objectfile);
if (_objectfile != null) {
writeObject(_objectfile);
_objectfile = file;
}
return;
}
if (OBJ == _load || OBJ == _loadb) {
file = selectFile(_objectfile);
if (file != null) {
read = readObject(_objectfile);
if (read == null) {
return;
}
_model = (IFCModel) read;
_model.register(this);
_objectfile = file;
}
return;
}
} catch (Exception EXC) {
System.out.println(EXC.getMessage());
EXC.printStackTrace();
}
} |
88e37c99-5d5d-44ca-b675-bba4e5ba7f38 | 6 | @Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Asystent Inwestora");
primaryStage.setMinHeight(600);
primaryStage.setMinWidth(800);
primaryStage.setMaximized(true);
// primaryStage.setFullScreen(true);
tabs = CreateTabs();
BorderPane borderPane = new BorderPane();
borderPane.setTop(tabs);
for (InvestorView v : views) {
v.InitView();
}
borderPane.setCenter(marketIndicicesView.getPane());
//Event handler do zakładek.
tabs.getSelectionModel().selectedItemProperty().addListener(
new ChangeListener<Tab>() {
@Override
public void changed(ObservableValue<? extends Tab> ov, Tab t, Tab t1) {
if (t1 == marketIndices) {
borderPane.setCenter(marketIndicicesView.getPane());
} else if (t1 == companies) {
borderPane.setCenter(companiesView.getPane());
} else if (t1 == currencies) {
borderPane.setCenter(currenciesView.getPane());
} else if (t1 == goods) {
borderPane.setCenter(goodsView.getPane());
}
// } else if (t1 == currenciesCorrelations) {
// borderPane.setCenter(currenciesCorrelationView.getPane());
// }
}
}
);
Scene scene = new Scene(borderPane, 800, 450);
primaryStage.setScene(scene);
//scene.getStylesheets().add(MainMenu.class.getResource("login.css").toExternalForm());
primaryStage.show();
} |
dc95cb20-b0c7-437d-b5f7-676d5fe10633 | 4 | private void validate(Budget budget, BudgetBreakdown budgetBreakdown) throws Exception {
if(budgetCalculation == null) {
throw new Exception("BudgetCalculation is null");
}
if(budget == null) {
throw new Exception("Budget is null.");
}
if(budget.getSalary() == null) {
throw new SalaryNotFoundException("Salary value is missing from budget.");
}
if(budgetBreakdown == null) {
throw new Exception("BudgetBreakdown is null.");
}
} |
7d86b989-3fee-4a18-9367-e9cbe578fa27 | 4 | private boolean method322(int z, int x, int y, int offsetZ) {
if (!method320(x, y, z))
return false;
int _x = x << 7;
int _y = y << 7;
return method324(_x + 1, _y + 1, heightMap[z][x][y] - offsetZ)
&& method324((_x + 128) - 1, _y + 1, heightMap[z][x + 1][y]
- offsetZ)
&& method324((_x + 128) - 1, (_y + 128) - 1,
heightMap[z][x + 1][y + 1] - offsetZ)
&& method324(_x + 1, (_y + 128) - 1, heightMap[z][x][y + 1]
- offsetZ);
} |
91e282bc-1207-4d6d-9b5d-8298bbc8c005 | 8 | @Override
public boolean equals(Object obj) {
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final ValueType other = (ValueType) obj;
if (this.javaType != other.javaType && (this.javaType == null || !this.javaType.equals(other.javaType))) {
return false;
}
if (this.defaultValue != other.defaultValue && (this.defaultValue == null || !this.defaultValue.equals(other.defaultValue))) {
return false;
}
return true;
} |
a0ab7491-d52b-4c94-be2f-2b522ab5e960 | 3 | private void requestBearerToken() throws IOException
{
// Do the OAUTH2 Authenticate
String oAuthTokenUrl = "https://api.twitter.com/oauth2/token";
URL tokenURL = new URL(oAuthTokenUrl);
HttpsURLConnection con = (HttpsURLConnection) tokenURL.openConnection();
con.setDoOutput(true);
con.setDoInput(true);
con.setRequestMethod("POST");
con.setRequestProperty("Host", "api.twitter.com");
con.setRequestProperty("Authorization", "Basic " + encodeKeys(oAuthCredentials));
con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
con.setUseCaches(false);
writeRequest(con, "grant_type=client_credentials");
// Parse the JSON response into a JSON mapped object to fetch fields from.
JSONObject obj = (JSONObject) JSONValue.parse(readResponse(con));
if (obj == null)
throw new IOException("Bearer token request failed."); //TODO: add to ResourceBundle
else
{
String tokenType = (String) obj.get("token_type");
String accessToken = (String) obj.get("access_token");
if(tokenType.equals("bearer") && (accessToken != null))
{
twitterBearerToken = new TwitterBearerToken();
twitterBearerToken.setTokenType(tokenType);
twitterBearerToken.setAccessToken(accessToken);
controller.appendStatus("token_type: " + twitterBearerToken.getTokenType()); //TODO: add to ResourceBundle
controller.appendStatus("access_token: " + twitterBearerToken.getAccessToken()); //TODO: add to ResourceBundle
}
}
con.disconnect();
} |
e1df8ed2-ab54-42c5-95d1-61dd6d81360f | 3 | public void update(GameContainer gc, StateBasedGame arg1, int delta)
throws SlickException {
super.update(gc, arg1, delta);
Input input = gc.getInput();
if(input.isMousePressed(Input.MOUSE_LEFT_BUTTON) && inputEnabled) {
Vector2 mousePos = new Vector2(input.getMouseX(), input.getMouseY());
mousePos = new Vector2(mousePos.getX() + camera.cameraX, mousePos.getY() + camera.cameraY);
destinationTile = GridGraphicTranslator.PixelsToGrid(mousePos);
if(!World.getWorld().getLayerMap().isBlocked(destinationTile)) {
player.moveTo(destinationTile);
} else {
destinationTile = null;
}
}
player.update(gc, delta);
} |
e0300fed-f958-43eb-a422-b9d0ffb3fa24 | 9 | private Component parseComponentContent(NodeList childNodes)
{
Component component = new Component();
for (int count = 0; count < childNodes.getLength(); count++)
{
Node node = childNodes.item(count);
if ("attribute".equals(node.getNodeName().toLowerCase()))
{
component.setName(parseNameAttribute(node));
continue;
}
if ("presents".equals(node.getNodeName().toLowerCase()))
{
component.setPresent(parseNameAttribute(node));
continue;
}
if ("field".equals(node.getNodeName().toLowerCase()))
{
Field field = parseField(node);
component.setField(field);
continue;
}
if ("constructor".equals(node.getNodeName().toLowerCase()))
{
Constructor constructor = new Constructor();
if (true == node.hasChildNodes())
constructor = parseContructorNodes(node.getChildNodes());
component.setConstructor ( constructor );
continue;
}
if ("procedure".equals(node.getNodeName().toLowerCase()))
{
Procedure procedure = new Procedure();
if (true == node.hasChildNodes())
procedure = parseProcedure(node.getChildNodes());
procedure.setType(parseProcedureAttributes(node));
component.setProcedure(procedure);
continue;
}
if ("behaviour".equals(node.getNodeName().toLowerCase()))
{
Behaviour behaviour = parseBehaviour(node.getChildNodes());
component.setBehaviour(behaviour);
behaviour = null;
continue;
}
}
return component;
} |
ada9a9d6-2067-4503-9b5b-5eb17a5ae06f | 6 | private void calcAngle() {
final double directionToAim = this.getAngle(this.location,
this.getAim());
if (this.direction != directionToAim) {
final double directionAtZero = this.direction - this.direction;
double directionToAimAtZero = directionToAim - this.direction;
if (directionToAimAtZero <= -PI) {
directionToAimAtZero += 2 * PI;
} else if (directionToAimAtZero > PI) {
directionToAimAtZero -= 2 * PI;
}
if (directionToAimAtZero > 0) {
if (directionAtZero + TURN < directionToAimAtZero) {
this.direction += TURN;
} else {
this.direction = directionToAim;
}
} else {
if (directionAtZero - TURN > directionToAimAtZero) {
this.direction -= TURN;
} else {
this.direction = directionToAim;
}
}
}
} |
8f64947c-7757-4d38-8331-7fdef74749d9 | 0 | public void setReplacement(String replacement) {this.replacement = replacement;} |
fd45e820-7ff7-492d-9ceb-8520ed146315 | 9 | public Component getComponentForDataSection(TaskObserver taskObserver, String dataSectionName) throws InterruptedException
{
if (dataSectionName == DATA_SECTION_GENERAL) { return getGeneralPanel(taskObserver); }
else if (dataSectionName == DATA_SECTION_SKILLS) { return getSkillsPanel(taskObserver); }
else if (dataSectionName == DATA_SECTION_KNOWN_SPELLS) { return getKnownSpellsPanel(taskObserver); }
else if (dataSectionName == DATA_SECTION_AWARDS) { return getAwardsPanel(taskObserver); }
else if (dataSectionName == DATA_SECTION_CONDITIONS) { return getConditionsPanel(taskObserver); }
else if (dataSectionName == DATA_SECTION_ACTIVE_SPELLS) { return getActiveSpellsPanel(taskObserver, null); }
else if (dataSectionName == DATA_SECTION_ITEMS) { return new ItemContainerControl(characterData.getItemContainer()); }
else if (dataSectionName == DATA_SECTION_LLOYDS_BEACON) { return getLloydsBeaconPanel(taskObserver, null); }
else if (dataSectionName == DATA_SECTION_UNKNOWNS) { return getUnknownsPanel(taskObserver, null, characterData.getUnknownByteDataList()); }
else throw new IllegalStateException("DataSection " + dataSectionName);
} |
8b525d13-786d-4495-a13a-30510e0626aa | 9 | public static void iterateOverMethods(Class<?> clz,Class<?> goUpto,ReflectionCallback<Method> callback) {
try{
for(Class<?> c=clz; c!=null && (goUpto==null || goUpto.isAssignableFrom(c)) ; c=c.getSuperclass()) {
for(Method m : c.getDeclaredMethods()) {
m.setAccessible(true);
if(callback.filter(m)) {
callback.consume(m);
}
}
}
}catch (Exception e){
throw new SwingObjectRunException(e, ReflectionUtils.class);
}
} |
bb95cafb-0bb6-4bae-a767-f7c4bf254044 | 9 | @Override
public String turnHardwareOn() {
String output = "";
mHardwareLayer.turnHardwareOn();
boolean compareFiles = false;
if (mMode == MachineMode.MANUAL){
try {
PrintWriter writer = new PrintWriter("Manual.DAS.csv", "UTF-8");
writer.println("Manual");
//turn hardware on and run it for time specified in control value
int elapsedTime = 0;
int runTime = mHardwareLayer.getControlValues().getmRunTime();
// System.out.println(runTime);
while (elapsedTime <= runTime){
ControlValues values = mHardwareLayer.getControlValues();
writer.println(elapsedTime + "," + values.getmAirPressure() + "," + values.getmElecCurrent());
elapsedTime++;
}
writer.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//turn off hardware
mHardwareLayer.turnHardwareOff();
return "Manual run successful! Check the Manual.DAS.csv file!";
}else{
if (mMode == MachineMode.CONSTANT_CURRENT){
runRecipe(new ConstantCurrentStrategy(mPartSize, mHardwareLayer, mRecipeFirstLine, mRecipeFile));
}
if (mMode == MachineMode.CONSTANT_PRESSURE){
runRecipe(new ConstantPressureStrategy(mPartSize, mHardwareLayer, mRecipeFirstLine, mRecipeFile));
}
if (mMode == MachineMode.RAMP){
if (mPartSize < 50){
return "Part size too small for Ramp mode. Part size must be 50 or bigger";
}else{
runRecipe(new RampStrategy(mPartSize, mHardwareLayer, mRecipeFirstLine, mRecipeFile));
}
}
compareFiles = compareFiles(mRecipeFile);
if (compareFiles){
return "Good part created. Check " + mRecipeFile + ".DAS.csv";
}else{
return "BAD PART! Check " + mRecipeFile + ".DAS.csv";
}
}
} |
cb8527c6-6d47-42c2-a9af-e789b6921ce4 | 9 | private void printDirListing(OutputStream out) {
// 4 kbyts - should be set-up before!
byte[] dir = new byte[4096];
int p = 0;
int adr = 0x801;
// Load address
dir[p++] = (byte) (adr & 0xff);
dir[p++] = (byte) (adr >> 8);
adr += label.length() + 5;
dir[p++] = (byte) (adr & 0xff);
dir[p++] = (byte) (adr >> 8);
dir[p++] = 0;
dir[p++] = 0;
dir[p++] = 0x12;
dir[p++] = '"';
// Disk label!
for (int i = 0, n = label.length(); i < n; i++) {
dir[p++] = (byte) label.charAt(i);
}
dir[p++] = '"';
dir[p++] = 0;
for (int i = 0, n = dirNames.size(); i < n; i++) {
DirEntry dire = (DirEntry) dirNames.get(i);
adr += 26;
int fill = 1;
if (dire.size < 10) fill = 3;
else if (dire.size < 100) fill = 2;
adr += fill;
// Address
dir[p++] = (byte) (adr & 0xff);
dir[p++] = (byte) (adr >> 8);
dir[p++] = (byte) (dire.size & 0xff);
dir[p++] = (byte) (dire.size >> 8);
for (int j = 0, m = fill; j < m; j++) {
dir[p++] = ' ';
}
for (int j = 0, m = dire.name.length(); j < m; j++) {
dir[p++] = (byte) dire.name.charAt(j);
}
// Fill up name...
for (int j = 0, m = 18 - dire.name.length(); j < m; j++) {
dir[p++] = ' ';
}
String type = dire.getTypeString();
for (int j = 0, m = type.length(); j < m; j++) {
dir[p++] = (byte) type.charAt(j);
}
dir[p++] = 0;
}
dir[p++] = 0;
dir[p++] = 0;
// Not inserted into memory yet...
try {
out.write(dir, 0, p);
} catch (Exception e) {
e.printStackTrace();
}
} |
7b958084-fef1-4a9c-a683-3d5307dfb666 | 3 | private void render() {
remove(gc);
gc.removeAll();
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
if (lab.getWalkways()[i][j]) {
gc.add(new GImage("blank.png", i*16, j*16));
} else {
gc.add(new GImage("wall.png", i*16, j*16));
}
}
}
add(gc);
} |
a5066508-2aa1-44ad-ad14-9e1c971ff044 | 5 | public void setColumnData(int i, Object value) throws Exception {
if (i == 0)
fileID = (String) value;
else if (i == 1)
projID = (String) value;
else if (i == 2)
format = (String) value;
else if (i == 3)
fileName = (String) value;
else if (i == 4)
location = (String) value;
else
throw new Exception("Error: invalid column index in courselist table");
} |
d2b718af-8b7d-4abf-92f6-d1a63091c94d | 6 | public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Frm_CadTipoUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Frm_CadTipoUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Frm_CadTipoUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Frm_CadTipoUsuario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Frm_CadTipoUsuario().setVisible(true);
}
});
} |
81f3596f-3dd7-48d4-b10f-b2fcf5d4c343 | 9 | static long f(int n) {
Arrays.fill(a, inf);
a[0] = 0;
long B = inf;
for (long t = 1; B == inf; t *= 10) {
Arrays.fill(b, inf);
for (int add = 0; add < L; ++add)
if (a[add] != inf) {
for (int m = 0; m < 10; ++m) {
int g = n * m + add;
int d = g % 10;
if (d > 2) continue;
g /= 10;
long h = t * m + a[add];
if (g < 3) if (h > 0) if (h < B) B = h;
if (h < b[g]) b[g] = h;
}
}
c = a;
a = b;
b = c;
}
return B;
} |
f268ab1b-01eb-4df4-a12f-5af444b1c617 | 6 | final Class367 method3832(int i, byte i_64_) {
if (i_64_ >= -57)
aClass209Array9795 = null;
int i_65_ = i;
while_234_:
do {
do {
if (-4 != (i_65_ ^ 0xffffffff)) {
if ((i_65_ ^ 0xffffffff) != -5) {
if (8 == i_65_)
break;
break while_234_;
}
} else
return new Class367_Sub5(this,
((DirectxToolkit) this).aClass45_8039);
return new Class367_Sub6(this, ((DirectxToolkit) this).aClass45_8039,
((DirectxToolkit) this).aClass269_7937);
} while (false);
return new Class367_Sub7(this, ((DirectxToolkit) this).aClass45_8039,
((DirectxToolkit) this).aClass269_7937);
} while (false);
return super.method3832(i, (byte) -74);
} |
2e3dfbbd-3488-43af-93f9-1891b3d62073 | 0 | public void setAlgorithm(String value) {
this.algorithm = value;
} |
eeb907b0-2962-498a-ae70-3cd6a976f84c | 1 | private boolean greater(Key i, Key j)
{
if (i.compareTo(j) > 0)
return true;
return false;
} |
edfdaa70-dd8f-442c-9b68-89bfcb2af68b | 7 | protected void cloneFix(StdArea areaA)
{
me=this;
basePhyStats=(PhyStats)areaA.basePhyStats().copyOf();
phyStats=(PhyStats)areaA.phyStats().copyOf();
properRooms =new STreeMap<String, Room>(new RoomIDComparator());
properRoomIDSet=null;
metroRoomIDSet =null;
parents=areaA.parents.copyOf();
children=areaA.children.copyOf();
if(areaA.blurbFlags!=null)
blurbFlags=areaA.blurbFlags.copyOf();
affects=new SVector<Ability>(1);
behaviors=new SVector<Behavior>(1);
scripts=new SVector<ScriptingEngine>(1);
derivedClimate=CLIMASK_INHERIT;
derivedTheme=THEME_INHERIT;
derivedAtmo=ATMOSPHERE_INHERIT;
for(final Enumeration<Behavior> e=areaA.behaviors();e.hasMoreElements();)
{
final Behavior B=e.nextElement();
if(B!=null)
behaviors.addElement((Behavior)B.copyOf());
}
for(final Enumeration<Ability> a=areaA.effects();a.hasMoreElements();)
{
final Ability A=a.nextElement();
if(A!=null)
affects.addElement((Ability)A.copyOf());
}
ScriptingEngine SE=null;
for(final Enumeration<ScriptingEngine> e=areaA.scripts();e.hasMoreElements();)
{
SE=e.nextElement();
if(SE!=null)
addScript((ScriptingEngine)SE.copyOf());
}
setSubOpList(areaA.getSubOpList());
} |
f681ae01-212f-4900-88b3-3fccee891b1d | 9 | public boolean isMatch(String s, String p) {
int i = 0;
int j = 0;
int star = -1;
int mark = -1;
while (i < s.length()) {
if (j < p.length()
&& (p.charAt(j) == '?' || p.charAt(j) == s.charAt(i))) {
++i;
++j;
} else if (j < p.length() && p.charAt(j) == '*') {
star = j++;
mark = i;
} else if (star != -1) {
j = star + 1;
i = ++mark;
} else {
return false;
}
}
while (j < p.length() && p.charAt(j) == '*') {
++j;
}
return j == p.length();
} |
6d2dfdcb-877e-4212-ab0b-2ecb8475238c | 2 | public void close() throws IOException {
if (socket != null) socket.close();
if (streamIn != null) streamIn.close();
} |
c2827f18-3367-4d16-af81-027418983a77 | 8 | public void actionPerformed(final ActionEvent EVENT) {
if (EVENT.getActionCommand().equals("flip") && flipping) {
previousSelectionIndex = currentSelectionIndex;
currentSelectionIndex++;
if (currentSelectionIndex >= selectedSet.size()) {
currentSelectionIndex = 0;
}
nextSelectionIndex = currentSelectionIndex + 1;
if (nextSelectionIndex >= selectedSet.size()) {
nextSelectionIndex = 0;
}
SwingUtilities.invokeLater(new Runnable() {
public void run() {
repaint(INNER_BOUNDS);
}
});
flipComplete = false;
if (selectedSet.get(currentSelectionIndex).equals(text)) {
flipping = false;
}
}
if (EVENT.getActionCommand().equals("flipSequence") && !flipComplete) {
if (currentFlipSeqImage == 9) {
currentFlipSeqImage = 0;
flipSequenceImage = null;
flipComplete = true;
repaint(INNER_BOUNDS);
} else {
flipSequenceImage = FlipImages.INSTANCE.getFlipImageArray()[currentFlipSeqImage];
currentFlipSeqImage++;
repaint(INNER_BOUNDS);
}
}
} |
dacc60ae-98c3-484b-98a0-1dfca62f16d7 | 8 | public void processOrder(String input) throws Exception {
String tokens[] = getTokenizedData(input);
DataValidator validator = new DataValidator();
if (validator.validateInput(tokens)) {
String fileName = tokens[0].trim();
RestaurtantDetailsLoader proc = new RestaurtantDetailsLoader();
restaurantMap = proc.loadRestaurantItemDetails(fileName);
priceMap = new HashMap<Integer, Float>();
bestRestaurantMealMap = new HashMap<Integer, List<String>>();
for (int id : restaurantMap.keySet()) {
populateRestaurantPriceMap(id, tokens);
}
Float minPrice = 0f;
for (int restaurantId : priceMap.keySet()) {
Float price = priceMap.get(restaurantId);
if (minPrice == 0) {
minPrice = price;
restaurantsList = new ArrayList<Integer>();
restaurantsList.add(restaurantId);
} else if (minPrice > price) {
minPrice = price;
restaurantsList = new ArrayList<Integer>();
restaurantsList.add(restaurantId);
} else if (minPrice.equals(price)) {
restaurantsList.add(restaurantId);
}
}
if (restaurantsList == null) {
System.out.println("No restaurants found as per the ordered placed....");
} else {
for (int id : restaurantsList) {
System.out.println("Restaurant Id: " + id + " price:: " + priceMap.get(id));
}
}
adviceMeal(tokens);
}
} |
c5894331-052c-47f5-995b-ace6851316d0 | 2 | public void tickDownTileStatuses(int currentPlayerIndex)
{
for (int y = 0; y < this.getGridHeight(); y++) {
for (int x = 0; x < this.getGridWidth(); x++) {
grid[x][y].tickDownStatuses(currentPlayerIndex);
}
}
} |
50d066fa-3eb1-4419-ab10-484b917fab63 | 1 | final void send(SocketChannel socket, ByteBuffer data) {
synchronized (mPendingWriteData) {
LinkedList<ByteBuffer> list = mPendingWriteData.get(socket);
if (list == null) {
list = new LinkedList<>();
mPendingWriteData.put(socket, list);
}
list.add(data);
}
synchronized (mPendingChanges) {
mPendingChanges.add(new ChangeRequest(socket, SelectionKey.OP_WRITE));
}
mSelector.wakeup();
} |
781f1fd3-eb75-42cf-b752-2273505e90f4 | 6 | public String stringTypeValue(keyTypeValues value)
{
String val = "string";
switch (value)
{
case BOOLEAN:
{
val = "boolean";
break;
}
case DOUBLE:
{
val = "double";
break;
}
case FLOAT:
{
val = "float";
break;
}
case INT:
{
val = "int";
break;
}
case LONG:
{
val = "long";
break;
}
case STRING:
{
val = "string";
break;
}
}
return val;
} |
7d369d52-5e53-4f71-b194-857d9e0dfe5a | 4 | public static void main(String[] args) {
String line = "";
String message = "";
int c;
try {
while ((c = System.in.read()) >= 0) {
switch (c) {
case '\n':
if (line.equals("go")) {
PlanetWars pw = new PlanetWars(message);
DoTurn(pw);
pw.FinishTurn();
message = "";
} else {
message += line + "\n";
}
line = "";
break;
default:
line += (char) c;
break;
}
}
} catch (Exception e) {
StringWriter writer = new StringWriter();
e.printStackTrace(new PrintWriter(writer));
String stackTrace = writer.toString();
System.err.println(stackTrace);
System.exit(1); //just stop now. we've got a problem
}
} |
def6bda4-f59d-40fa-931b-58ca9d9d3c98 | 6 | private void attack(Civilization c) {
if (c.cities.size()>0&&cities.size()>0) {
City best=cities.get(0),target=c.cities.get(0);
int attackGuess=aggression*best.population/100*(strength+getBonus(target.CENTER)-best.CENTER.distanceTo(target.CENTER)*distanceWeight);
int defendGuess=c.aggression*target.population/100*(c.strength+c.getBonus(target.CENTER));
int max=attackGuess-defendGuess;
int cur;
for (City c1:cities)
for (City c2:c.cities) {
attackGuess=aggression*c1.population/100*(strength+getBonus(c2.CENTER)-c1.CENTER.distanceTo(c2.CENTER));
defendGuess=c.aggression*c2.population/100*(c.strength+c.getBonus(c2.CENTER));
cur=attackGuess-defendGuess;
if (cur>max) {
max=cur;
best=c1;
target=c2;
}
}
if (max>-50) //This specifies how good a chance of victory they require to attack
best.attack(target);
}
} |
91e1c05a-8a97-4d9e-8752-7c8f66310117 | 0 | public static void main(String[] args) {
CameraCaptureTester tester = new CameraCaptureTester();
tester.run();
} |
07d0bdc0-616b-40c4-ba64-0a849671f2a0 | 2 | public static void main(String[] args)
{
Graph G = null;
try
{
G = new Graph(new In(args[0]));
}
catch (Exception e)
{
System.out.println(e);
System.exit(1);
}
Bipartite b = new Bipartite(G);
if (b.isBipartite())
System.out.println(args[0] + " is bipartite");
else
System.out.println(args[0] + " is NOT bipartite");
System.out.println("\n" + G);
} |
723edba9-129b-418b-b1f6-f4c8939e39b7 | 1 | public static void main(String[] args) {
Pattern pat = Pattern.compile(".*?xx");
Matcher mat = pat.matcher("yyxxxyxx");
while(mat.find()){
System.out.println("Start:"+mat.start());
System.out.println("Group..:"+mat.group());
}
} |
f92bc667-38e8-4248-901a-8af9c8f729f8 | 8 | public boolean attemptToMove(double delta, Tile[] tiles) {
// Store our already (hopefully) collision-free position
px = x;
py = y;
float timeslicesRemaining = 1.0f;
int numberOfTimesSubdivided = 0;
boolean collided;
Collision collision = new Collision();
Collision bestCollision = new Collision();
while (timeslicesRemaining > TIMESLICE_EPSILON) {
bestCollision.time = 1.0f + TIMESLICE_EPSILON;
collided = false;
//LATER only check the four chunks near us
for (int i = 0; i < tiles.length; i++) {
if (intersectionTest(tiles[i], collision)) {
System.out.println(t++);
if (collision.time < bestCollision.time || collision.time < bestCollision.time + TIMESLICE_EPSILON
&& collision.surfaceArea > bestCollision.surfaceArea) {
collided = true;
bestCollision = collision.copy();
}
}
}
if (!collided) return false;
resolveCollision(delta, bestCollision, timeslicesRemaining);
timeslicesRemaining = (1.0f - bestCollision.time) * timeslicesRemaining;
numberOfTimesSubdivided++;
if (numberOfTimesSubdivided > MAX_TIMESLICE_SUBDIVISIONS) {
System.err.println("Warning! Maximum timeslice subdivisions reached! Collision resolution may be incomplete");
break;
}
}
return true;
} |
b92f7005-3c93-44eb-bc80-88321818041f | 0 | public JButton getjButtonNew() {
return jButtonNew;
} |
0244427a-90ea-4e94-8fc0-a2cbb2c2d52b | 6 | public static void openWorkbench(Player player) {
//has to have the use permission
if (!permission.has(player.getWorld(), player.getName(), "portables.workbench.use")) {
return;
}
//has to be holding the material
if (permission.has(player.getWorld(), player.getName(), "portables.workbench.has")) {
//Doesn't have it
if (!hasMaterial(Material.WORKBENCH, player.getInventory().getContents())) {
return;
}
}
//has to pay for it
if (PortablesPlugin.getCached().useEconomy() && permission.has(player.getWorld(), player.getName(), "portables.workbench.cost")) {
if (!econ.has(player.getName(), PortablesPlugin.getCached().getWorkbenchCost())) {
player.sendMessage(ChatColor.GREEN + "[Portables] " + ChatColor.RED + " Insufficient Funds to open requested item.");
return;
}
double cost = PortablesPlugin.getCached().getWorkbenchCost();
econ.withdrawPlayer(player.getName(), cost);
player.sendMessage(ChatColor.GREEN + "[Portables] " + ChatColor.WHITE + " Account deducted: " + econ.format(cost) + ".");
}
player.openWorkbench(null, true);
} |
7b6eeaad-59f8-4d59-a2fa-2d8c9a088a83 | 5 | protected void processChange(Rectangle paramRectangle)
{
Rectangle localRectangle1 = getBounds();
if (this.BufferSize != null) {
localRectangle1.setSize(this.BufferSize);
}
if (paramRectangle.intersects(localRectangle1))
{
paramRectangle = paramRectangle.intersection(localRectangle1);
taintBuffer(paramRectangle);
if (this.Frozen == false)
{
if (this.ImageContainerParent == null)
{
repaint(paramRectangle.x, paramRectangle.y, paramRectangle.width, paramRectangle.height);
return;
}
Rectangle localRectangle2 = new Rectangle(paramRectangle);
ImageContainer localImageContainer = this;
while (localImageContainer.getImageContainerParent() != null)
{
localRectangle2.translate(localImageContainer.getLocation().x, localImageContainer.getLocation().y);
localImageContainer = localImageContainer.getImageContainerParent();
}
localImageContainer.repaint(localRectangle2.x, localRectangle2.y, localRectangle2.width, localRectangle2.height);
}
}
} |
cffc74a9-04fd-4a2f-83fa-ce4ff513a6b1 | 1 | public static void main(String[] args) {
HttpClient httpClient = HttpClientBuilder.create().build();
try {
HttpPost request = new HttpPost("http://localhost:8080/register");
StringEntity params =new StringEntity("userJson={\"id\":\"100\",\"age\":\"20\",\"name\":\"Purnima\"}");
// request.addHeader("content-type", "application/x-www-form-urlencoded");
request.addHeader("content-type", "application/json");
request.setEntity(params);
HttpResponse response = httpClient.execute(request);
System.out.println(response);
// handle response here...
}catch (Exception ex) {
// handle exception here
} finally {
httpClient.getConnectionManager().shutdown(); //Deprecated
}
} |
1679dcac-c208-4e8b-9054-2fa456dd369c | 0 | public EventCommentType(final String name) {
super(name);
} |
e4f67902-3cce-45d9-8df8-ef449ce19724 | 5 | public static void main(String[] args) {
Employee e1 = new Employee("Tom", "Tommerson", "555-55-5555");
Employee e2 = new Employee("Sneaky", "Sneakerson", "444-55-5555");
Employee e3 = new Employee("Sally", "Sallerson", "333-55-5555");
Employee e4 = new Employee("Bill", "Billerson", "444-55-5555");
Employee e5 = new Employee("John", "Adams", "999-99-9999");
List<Employee> employees = new ArrayList<>();
employees.add(e1);
employees.add(e2);
employees.add(e3);
employees.add(e4);
employees.add(e5);
Map<String, Employee> employeeTreeMap = new TreeMap<>();
//Fill the TreeMap
for (Employee e : employees) {
employeeTreeMap.put(e.getSsn(), e);
}
System.out.println("Values in Map:");
for (String key : employeeTreeMap.keySet()) {
System.out.println(employeeTreeMap.get(key));
}
System.out.println();
Collection<Employee> employeeObjects = employeeTreeMap.values();
List<Employee> orderedEmployeeList = new ArrayList<>(employeeObjects);
System.out.println("Values in map ordered by First Name:");
Collections.sort(orderedEmployeeList, new EmployeeByFirstName());
for (Employee em : orderedEmployeeList) {
System.out.println(em);
}
System.out.println();
System.out.println("Values in map ordered by Last Name:");
Collections.sort(orderedEmployeeList, new EmployeeByLastName());
for (Employee em : orderedEmployeeList) {
System.out.println(em);
}
System.out.println();
System.out.println("Values in map ordered by SSN:");
Collections.sort(orderedEmployeeList, new EmployeeBySSN());
for (Employee em : orderedEmployeeList) {
System.out.println(em);
}
} |
dbed752d-5dbb-4a87-8ab1-031bb43fd965 | 1 | public boolean deliverToMemory(boolean isRead) { //If isRead, first stage of read operation, otherwise write.
if (isRead) {
return memory.notifyRead(addressBus.read());
}
fireOperationUpdate(""); //Reset control line GUI display as data is written into MBR
return memory.notifyWrite(addressBus.read(), dataBus.read());
} |
7329938f-c192-4c1f-820f-e00fca479706 | 1 | public ResultSet executeSQLQuery(String sqlStatement) {
try {
// Datenbankverbindung herstellen
connect = connectDB();
// PreparedStatement für den SQL-Befehl
myPreparedStatement = connect.prepareStatement(sqlStatement);
// SQL-Befehl wird ausgeführt
myResultSet = myPreparedStatement.executeQuery();
} catch (Exception e) {
System.out.println(e.toString());
// Ein Dialogfenster mit entsprechender Meldung soll erzeugt werden
String errorText = "Datenbankabfrage Fehler!";
errorMessage.showMessage(errorText);
}
return myResultSet;
} |
685b2d4d-b64c-4331-9964-fa028c3316f7 | 1 | @SuppressWarnings("static-access")
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerDropItem (PlayerDropItemEvent event) {
Random rand = new Random();
int possessionChance = rand.nextInt(5);
final ItemStack droppedStack = event.getItemDrop().getItemStack();
final Entity droppedStackEntity = event.getItemDrop();
final Location stackLoc = event.getItemDrop().getLocation();
if (possessionChance == 1) {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
public void run () {
droppedStackEntity.remove();
MMPossessedItem.spawnPossessedItem(stackLoc, 1, droppedStack);
}
}, 200L);
}
} |
8c736045-e873-4b13-81ca-a1c1494a8b23 | 8 | public static void internalComponents0(Collection<Class<?>> comps, Class<?> model) {
for (Field f : model.getDeclaredFields()) {
f.setAccessible(true);
Class<?> fc = f.getType();
if (!fc.isPrimitive() && !fc.getName().startsWith("java.") && isComponentClass(fc)) {
if (!comps.contains(fc)) {
comps.add(fc);
internalComponents0(comps, fc);
}
}
}
} |
9ee9548a-0eb1-4e33-b051-a13058c2b207 | 0 | @Override
//TODO: Need to put error check, make sure there is only one letter popping and placing
// More error check?
protected boolean checkAutomaton() {
// TODO Auto-generated method stub
//return true for now
return true;
} |
8e916d52-cdc8-41bb-8a08-9948b062cc3b | 8 | BitMatrix buildFunctionPattern() {
int dimension = getDimensionForVersion();
BitMatrix bitMatrix = new BitMatrix(dimension);
// Top left finder pattern + separator + format
bitMatrix.setRegion(0, 0, 9, 9);
// Top right finder pattern + separator + format
bitMatrix.setRegion(dimension - 8, 0, 8, 9);
// Bottom left finder pattern + separator + format
bitMatrix.setRegion(0, dimension - 8, 9, 8);
// Alignment patterns
int max = alignmentPatternCenters.length;
for (int x = 0; x < max; x++) {
int i = alignmentPatternCenters[x] - 2;
for (int y = 0; y < max; y++) {
if ((x == 0 && (y == 0 || y == max - 1)) || (x == max - 1 && y == 0)) {
// No alignment patterns near the three finder paterns
continue;
}
bitMatrix.setRegion(alignmentPatternCenters[y] - 2, i, 5, 5);
}
}
// Vertical timing pattern
bitMatrix.setRegion(6, 9, 1, dimension - 17);
// Horizontal timing pattern
bitMatrix.setRegion(9, 6, dimension - 17, 1);
if (versionNumber > 6) {
// Version info, top right
bitMatrix.setRegion(dimension - 11, 0, 3, 6);
// Version info, bottom left
bitMatrix.setRegion(0, dimension - 11, 6, 3);
}
return bitMatrix;
} |
b4487676-d5c4-4464-b220-68c5dd7ca490 | 6 | /* */ public Object getDestroyPacket()
/* */ {
/* 83 */ Class<?> PacketPlayOutEntityDestroy = Util.getCraftClass("PacketPlayOutEntityDestroy");
/* */
/* 85 */ Object packet = null;
/* */ try {
/* 87 */ packet = PacketPlayOutEntityDestroy.newInstance();
/* 88 */ Field a = PacketPlayOutEntityDestroy.getDeclaredField("a");
/* 89 */ a.setAccessible(true);
/* 90 */ a.set(packet, new int[] { this.id });
/* */ } catch (SecurityException e) {
/* 92 */ e.printStackTrace();
/* */ } catch (NoSuchFieldException e) {
/* 94 */ e.printStackTrace();
/* */ } catch (InstantiationException e) {
/* 96 */ e.printStackTrace();
/* */ } catch (IllegalAccessException e) {
/* 98 */ e.printStackTrace();
/* */ } catch (IllegalArgumentException e) {
/* 100 */ e.printStackTrace();
/* */ }
/* */
/* 103 */ return packet;
/* */ } |
dad7b56a-401b-4cc2-9106-bec8e55a7e45 | 0 | public JSONWriter endArray() throws JSONException {
return this.end('a', ']');
} |
d805d70a-bb4e-4b78-ba41-2f8b8bada4c2 | 6 | public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(frmPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(frmPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(frmPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(frmPrincipal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new frmPrincipal().setVisible(true);
}
});
} |
8b65a403-17d1-4112-bda7-0ed0645aae64 | 9 | private void checkBody() throws Exception {
Token token;
while(iterator < tokenList.size()) {
token = tokenList.get(iterator++);
if(token.getType() == TokenType.BOOL_TYPE || token.getType() == TokenType.CHAR_TYPE ||
token.getType() == TokenType.INT_TYPE) {
checkVarDeclaration();
} else if(token.getType() == TokenType.IF_DECL) {
checkIfDeclaration();
} else if(token.getType() == TokenType.WHILE_DECL) {
checkWhileDeclaration();
} else if(token.getType() == TokenType.ID) {
checkAttribution();
} else if(token.getType() == TokenType.PRINT) {
checkPrintFunction();
} else if(token.getType() == TokenType.R_BRACE) {
braceStack--;
return;
}
}
} |
80986740-97ff-4543-a88d-726e41c917da | 7 | @Override
public <T> Invoker<T> refer(final Class<T> type, final TpURL tpURL) throws RpcException {
// 获得一个 服务类 对应的 remote 请求代理
T referProxy = doRefer(type, tpURL);
// 将这个请求代理进行包装,生成一个Invoker 具有远程调用外部service的能力
final Invoker<T> target = proxyFactory.createProxyInvoker(referProxy, type, tpURL);
// 生成一个AbstractInvoker 含有封装执行异常 , invocation 处理的功能 可以理解成一个静态代理
// target.invoke 将会在 AbstractInvoker.invoke 方法中被执行
Invoker<T> invoker = new AbstractInvoker<T>(type, tpURL) {
@Override
protected Result doInvoke(Invocation invocation) throws Throwable {
try {
Result result = target.invoke(invocation);
// 处理异常 存在异常时将异常抛出,由AbstractInvoker捕获并重建 Result
Throwable e = result.getException();
if (e != null) {
for (Class<?> rpcException : rpcExceptions) {
if (rpcException.isAssignableFrom(e.getClass())) {
throw getRpcException(type, tpURL, invocation, e);
}
}
}
return result;
} catch (RpcException e) {
if (e.getCode() == RpcException.UNKNOWN_EXCEPTION) {
e.setCode(getErrorCode(e.getCause()));
}
throw e;
} catch (Throwable e) {
throw getRpcException(type, tpURL, invocation, e);
}
}
};
invokers.add(invoker);
return invoker;
} |
741adc1b-908a-4f4f-83cc-effc9eccb36b | 0 | public static void start() throws IOException
{
new Listener();
} |
c48461a4-c0b6-44a8-b916-a6daf54b16ad | 9 | @Override
public void run() {
if(state==GameState.Running){
while (true) {
robot.update();
if (robot.isJumped()) {
currentSprite = characterJumped;
} else if (robot.isJumped() == false && robot.isDucked() == false) {
currentSprite = anim.getImage();
}
ArrayList projectiles = robot.getProjectiles();
for (int i = 0; i < projectiles.size(); i++) {
Projectile p = (Projectile) projectiles.get(i);
if (p.isVisible() == true) {
p.update();
} else {
projectiles.remove(i);
}
}
updateTiles();
hb.update();
hb2.update();
bg1.update();
bg2.update();
animate();
repaint();
try {
Thread.sleep(17);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (robot.getCenterY() > 500){
state = GameState.Dead;
}
}
}
} |
bd99bba1-64c8-48e0-8620-9ca35dbed432 | 8 | public boolean blockLeftClick(Block block, Player player) {
// If the block we're clicking is a chest, no point doing anything
if(block.getType() == Material.CHEST)
return true;
// Get the material in the hand
Material inHand = player.getItemInHand().getType();
// They're not interacting with a block
if(inHand == Material.AIR || inHand.getId() > 127)
return true;
// Make sure the chest is the same as the one in the hand
if(block.getType() != inHand)
return true;
// What world are we in?
World world = block.getWorld();
// Get the HiddenChest (or null)
HiddenChest hidden = data.getHiddenChest(block);
// If it's null, no point doing anything
if(hidden == null)
return true;
// If the player doesn't have permission to transform the Chest into a HiddenChest, don't do anything
if(!player.hasPermission("hiddenchest.transform."+inHand.getId()))
return true;
// Get the Block[] array
Block[] blocks = hidden.getBlocks();
// And set them to chests
for(Block b : blocks)
b.setType(Material.CHEST);
// Now that it's a chest we change the reference to the Block object
block = world.getBlockAt(block.getLocation());
if(!(block.getState() instanceof Chest))
return true;
// Now define the Chest
Chest chest = (Chest) block.getState();
// And set the contents
chest.getInventory().setContents(hidden.getContents());
// Update the chest
chest.update();
// And remove the reference to the HiddenChest
data.remove(hidden);
// And cancel the event, for neatness
return false;
} |
f2921e72-8fb6-4b34-ab08-98af240e7295 | 3 | private boolean isPasswordAndConfirmEquals() {
boolean result = false;
boolean passwordAndConfirmIsValid = isPasswordValidate() && isConfirmValidate();
if(passwordAndConfirmIsValid) {
result = this.password.equals(this.password_confirm) ? true: false;
}
return result;
} |
d62de868-6f21-4494-ba3f-5d1caa191744 | 9 | public static void main(String[] args) {
LinearAlgebraScanner input = new LinearAlgebraScanner();
boolean done = false;
System.out.println("Howdy!");
System.out.println("This heres the greatest calculator ever");
System.out.println("created with 10 functions or less.");
while (!done) {
try {
System.out.println();
System.out.println("What would you like to do?");
System.out.println("0. matrix + matrix");
System.out.println("1. matrix * vector");
System.out.println("2. vector . vector");
System.out.println("3. vector + vector");
System.out.println("4. Exit\n");
String line = input.nextLine();
int userInput = Integer.parseInt(line);
System.out.println();
if (userInput == 0) {
System.out.println("Please enter a matrix!");
System.out.println("Enter empty line to terminate!");
Matrix m1 = input.readMatrix();
System.out.println("Please enter a matrix!");
System.out.println("Enter empty line to terminate!");
Matrix m2 = input.readMatrix();
System.out.println();
System.out.println(LinearAlgebra.matrixAdd(m1, m2));
} else if (userInput == 1) {
System.out.println("Please enter a matrix!");
System.out.println("Enter empty line to terminate!");
Matrix m1 = input.readMatrix();
System.out.println("Please enter a vector!");
Vector v1 = input.readVector();
System.out.println();
System.out.println();
System.out.println(
LinearAlgebra.matrixVectorMultiply(m1, v1));
} else if (userInput == 2) {
System.out.println("Please enter a vector!");
System.out.println("Separate vector components by "
+ "using a space.");
Vector v1 = input.readVector();
System.out.println();
System.out.println("Please enter a vector!");
System.out.println("Separate vector components by "
+ "using a space.");
Vector v2 = input.readVector();
System.out.println();
System.out.println();
System.out.println(LinearAlgebra.dotProduct(v1, v2));
} else if (userInput == 3) {
System.out.println("Please enter a vector!");
System.out.println("Separate vector components by "
+ "using a space.");
Vector v1 = input.readVector();
System.out.println();
System.out.println("Please enter a vector!");
System.out.println("Separate vector components by "
+ "using a space.");
Vector v2 = input.readVector();
System.out.println();
System.out.println();
System.out.println(LinearAlgebra.vectorAdd(v1, v2));
} else if (userInput == 4) {
done = true;
}
} catch (InputMismatchException e) {
System.out.println("Your input did not match the "
+ "required format.");
System.out.println(e.getMessage());
} catch (IllegalOperandException e) {
System.out.println("The dimensions of your input "
+ "do not agree.");
System.out.println(e.getMessage());
} catch (NumberFormatException e) {
System.out.println("Enter a valid number to choose "
+ "your calculation.");
System.out.println(e.getMessage());
}
}
} |
70cfccbe-f11f-49ff-ad7d-14de46a3f0eb | 0 | static void actionLikeA(A a) {
a.action();
} |
a606e5da-985e-4aab-8b84-62e2f2677d01 | 4 | private void descripcionmedicamentosFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_descripcionmedicamentosFieldKeyTyped
// TODO add your handling code here:
if (!Character.isLetter(evt.getKeyChar()) && !Character.isISOControl(evt.getKeyChar()) && !Character.isWhitespace(evt.getKeyChar()))
{
Toolkit.getDefaultToolkit().beep();
evt.consume();
}
if(descripcionmedicamentosField.getText().length() == 100)
{
Toolkit.getDefaultToolkit().beep();
evt.consume();
JOptionPane.showMessageDialog(this, "Descripcion demasiado larga", "ADVERTENCIA", WIDTH);
}
}//GEN-LAST:event_descripcionmedicamentosFieldKeyTyped |
db72b3a8-43b1-478f-ac51-ea438ab3ac87 | 6 | public void foreachPoms(POMHandler handler) {
init();
// process the ignored pom files
for (String pomPath: pomOptions.keySet()) {
POMOptions options = getPOMOptions(pomPath);
if (options.isIgnore()) {
File pom = new File(baseDir, pomPath);
try {
handler.ignorePOM(pom);
} catch (Exception e) {
log.log(Level.SEVERE, "An error occured when processing the ignored pom file " + pom, e);
}
}
}
// process the included pom files
for (String pomPath: pomOptions.keySet()) {
POMOptions options = getPOMOptions(pomPath);
if (!options.isIgnore()) {
File pom = new File(baseDir, pomPath);
try {
handler.handlePOM(pom, options.isNoParent(), options.getHasPackageVersion());
} catch (Exception e) {
log.log(Level.SEVERE, "An error occured when processing the pom file " + pom, e);
}
}
}
} |
11407bfd-6e01-4578-b8f8-2b672d1ea645 | 2 | @Override
public int hashCode() {
int result = userSession != null ? userSession.hashCode() : 0;
result = 31 * result + (watcherSession != null ? watcherSession.hashCode() : 0);
return result;
} |
dc3673f0-a717-4e2c-a1d2-f9ed0b13e1a3 | 5 | private boolean zzRefill() throws java.io.IOException {
/* first: make room (if you can) */
if (zzStartRead > 0) {
System.arraycopy(zzBuffer, zzStartRead,
zzBuffer, 0,
zzEndRead-zzStartRead);
/* translate stored positions */
zzEndRead-= zzStartRead;
zzCurrentPos-= zzStartRead;
zzMarkedPos-= zzStartRead;
zzStartRead = 0;
}
/* is the buffer big enough? */
if (zzCurrentPos >= zzBuffer.length) {
/* if not: blow it up */
char newBuffer[] = new char[zzCurrentPos*2];
System.arraycopy(zzBuffer, 0, newBuffer, 0, zzBuffer.length);
zzBuffer = newBuffer;
}
/* finally: fill the buffer with new input */
int numRead = zzReader.read(zzBuffer, zzEndRead,
zzBuffer.length-zzEndRead);
if (numRead > 0) {
zzEndRead+= numRead;
return false;
}
// unlikely but not impossible: read 0 characters, but not at end of stream
if (numRead == 0) {
int c = zzReader.read();
if (c == -1) {
return true;
} else {
zzBuffer[zzEndRead++] = (char) c;
return false;
}
}
// numRead < 0
return true;
} |
b7d3e21d-de88-4b54-ab5c-db7458077d94 | 7 | public static void startupExplanations() {
{ Object old$Module$000 = Stella.$MODULE$.get();
Object old$Context$000 = Stella.$CONTEXT$.get();
try {
Native.setSpecial(Stella.$MODULE$, Stella.getStellaModule("/LOGIC", Stella.$STARTUP_TIME_PHASE$ > 1));
Native.setSpecial(Stella.$CONTEXT$, ((Module)(Stella.$MODULE$.get())));
if (Stella.currentStartupTimePhaseP(2)) {
_StartupExplanations.helpStartupExplanations1();
}
if (Stella.currentStartupTimePhaseP(4)) {
_StartupExplanations.helpStartupExplanations2();
}
if (Stella.currentStartupTimePhaseP(5)) {
_StartupExplanations.helpStartupExplanations3();
}
if (Stella.currentStartupTimePhaseP(6)) {
Stella.finalizeClasses();
}
if (Stella.currentStartupTimePhaseP(7)) {
Stella.defineFunctionObject("EXPLANATION-TRUTH-MARKER", "(DEFUN (EXPLANATION-TRUTH-MARKER STRING) ((JUSTIFICATION JUSTIFICATION)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "explanationTruthMarker", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification")}), null);
Stella.defineFunctionObject("DEFINE-EXPLANATION-PHRASE", "(DEFUN DEFINE-EXPLANATION-PHRASE ((PHRASEKEY KEYWORD) (AUDIENCE KEYWORD) (PHRASE STRING) |&REST| (MODIFIERS KEYWORD)))", Native.find_java_method("edu.isi.powerloom.logic.Logic", "defineExplanationPhrase", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Keyword"), Native.find_java_class("edu.isi.stella.Keyword"), Native.find_java_class("java.lang.String"), Native.find_java_class("edu.isi.stella.Cons")}), null);
Stella.defineFunctionObject("LOOKUP-EXPLANATION-PHRASE", "(DEFUN (LOOKUP-EXPLANATION-PHRASE STRING) ((PHRASEKEY KEYWORD) (MODIFIERS (CONS OF KEYWORD)) (AUDIENCE KEYWORD)))", Native.find_java_method("edu.isi.powerloom.logic.Logic", "lookupExplanationPhrase", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Keyword"), Native.find_java_class("edu.isi.stella.Cons"), Native.find_java_class("edu.isi.stella.Keyword")}), null);
Stella.defineFunctionObject("REGISTER-JUSTIFICATION", "(DEFUN (REGISTER-JUSTIFICATION EXPLANATION-INFO) ((SELF JUSTIFICATION) (MAPPING EXPLANATION-MAPPING)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "registerJustification", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification"), Native.find_java_class("edu.isi.stella.KeyValueList")}), null);
Stella.defineFunctionObject("GET-EXPLANATION-INFO", "(DEFUN (GET-EXPLANATION-INFO EXPLANATION-INFO) ((SELF JUSTIFICATION) (MAPPING EXPLANATION-MAPPING) (CREATE? BOOLEAN)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "getExplanationInfo", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification"), Native.find_java_class("edu.isi.stella.KeyValueList"), java.lang.Boolean.TYPE}), null);
Stella.defineFunctionObject("EXPLANATION-INFO", "(DEFUN (EXPLANATION-INFO EXPLANATION-INFO) ((SELF JUSTIFICATION) (MAPPING EXPLANATION-MAPPING)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "explanationInfo", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification"), Native.find_java_class("edu.isi.stella.KeyValueList")}), null);
Stella.defineFunctionObject("LOOKUP-JUSTIFICATION", "(DEFUN (LOOKUP-JUSTIFICATION JUSTIFICATION) ((MAPPING EXPLANATION-MAPPING) (LABEL STRING)))", Native.find_java_method("edu.isi.powerloom.logic.Logic", "lookupJustification", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.KeyValueList"), Native.find_java_class("java.lang.String")}), null);
Stella.defineFunctionObject("RESET-MAPPING-FOR-SUBEXPLANATION", "(DEFUN RESET-MAPPING-FOR-SUBEXPLANATION ((MAPPING EXPLANATION-MAPPING)))", Native.find_java_method("edu.isi.powerloom.logic.Logic", "resetMappingForSubexplanation", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.KeyValueList")}), null);
Stella.defineFunctionObject("PRINT-EXPLANATION", "(DEFUN (PRINT-EXPLANATION EXPLANATION-MAPPING) ((SELF JUSTIFICATION) (STREAM OUTPUT-STREAM) (MAPPING EXPLANATION-MAPPING) (MAXDEPTH INTEGER) (AUDIENCE KEYWORD)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "printExplanation", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification"), Native.find_java_class("edu.isi.stella.OutputStream"), Native.find_java_class("edu.isi.stella.KeyValueList"), java.lang.Integer.TYPE, Native.find_java_class("edu.isi.stella.Keyword")}), null);
Stella.defineFunctionObject("PRINT-EXPLANATION-SUPPORT", "(DEFUN PRINT-EXPLANATION-SUPPORT ((SELF JUSTIFICATION) (STREAM OUTPUT-STREAM) (MAPPING EXPLANATION-MAPPING) (MAXDEPTH INTEGER) (UNEXPLAINED (LIST OF JUSTIFICATION))))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "printExplanationSupport", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification"), Native.find_java_class("edu.isi.stella.OutputStream"), Native.find_java_class("edu.isi.stella.KeyValueList"), java.lang.Integer.TYPE, Native.find_java_class("edu.isi.stella.List")}), null);
Stella.defineFunctionObject("PRINT-ONE-EXPLANATION", "(DEFUN PRINT-ONE-EXPLANATION ((SELF JUSTIFICATION) (STREAM OUTPUT-STREAM) (MAPPING EXPLANATION-MAPPING) (MAXDEPTH INTEGER) (UNEXPLAINED (LIST OF JUSTIFICATION))))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "printOneExplanation", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification"), Native.find_java_class("edu.isi.stella.OutputStream"), Native.find_java_class("edu.isi.stella.KeyValueList"), java.lang.Integer.TYPE, Native.find_java_class("edu.isi.stella.List")}), null);
Stella.defineFunctionObject("PRINTING-JUSTIFICATION?", "(DEFUN (PRINTING-JUSTIFICATION? BOOLEAN) () :GLOBALLY-INLINE? TRUE (RETURN (DEFINED? *CURRENTJUSTIFICATION*)))", Native.find_java_method("edu.isi.powerloom.logic.Logic", "printingJustificationP", new java.lang.Class [] {}), null);
Stella.defineFunctionObject("PRINT-JUSTIFICATION-PROPOSITION-FOR-FORMAT", "(DEFUN PRINT-JUSTIFICATION-PROPOSITION-FOR-FORMAT ((SELF JUSTIFICATION) (STREAM OUTPUT-STREAM) (INDENT INTEGER)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "printJustificationPropositionForFormat", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification"), Native.find_java_class("edu.isi.stella.OutputStream"), java.lang.Integer.TYPE}), null);
Stella.defineFunctionObject("PRINT-JUSTIFICATION-PROPOSITION", "(DEFUN PRINT-JUSTIFICATION-PROPOSITION ((SELF JUSTIFICATION) (STREAM OUTPUT-STREAM) (INDENT INTEGER)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "printJustificationProposition", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification"), Native.find_java_class("edu.isi.stella.OutputStream"), java.lang.Integer.TYPE}), null);
Stella.defineFunctionObject("PRINT-EXPLANATION-LABEL", "(DEFUN PRINT-EXPLANATION-LABEL ((STREAM OUTPUT-STREAM) (LABEL STRING) (HEAD? BOOLEAN)))", Native.find_java_method("edu.isi.powerloom.logic.Logic", "printExplanationLabel", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.OutputStream"), Native.find_java_class("java.lang.String"), java.lang.Boolean.TYPE}), null);
Stella.defineFunctionObject("PRINT-EXPLANATION-HEADER", "(DEFUN PRINT-EXPLANATION-HEADER ((SELF JUSTIFICATION) (STREAM OUTPUT-STREAM) (MAPPING EXPLANATION-MAPPING)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "printExplanationHeader", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification"), Native.find_java_class("edu.isi.stella.OutputStream"), Native.find_java_class("edu.isi.stella.KeyValueList")}), null);
Stella.defineFunctionObject("PRINT-EXPLANATION-TEXT", "(DEFUN PRINT-EXPLANATION-TEXT ((SELF JUSTIFICATION) (STREAM OUTPUT-STREAM) (MAPPING EXPLANATION-MAPPING)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "printExplanationText", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification"), Native.find_java_class("edu.isi.stella.OutputStream"), Native.find_java_class("edu.isi.stella.KeyValueList")}), null);
Stella.defineFunctionObject("MARK-AS-EXPLICIT-ASSERTION?", "(DEFUN (MARK-AS-EXPLICIT-ASSERTION? BOOLEAN) ((SELF JUSTIFICATION)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "markAsExplicitAssertionP", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification")}), null);
Stella.defineFunctionObject("MARK-AS-FAILED-GOAL?", "(DEFUN (MARK-AS-FAILED-GOAL? BOOLEAN) ((SELF JUSTIFICATION)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "markAsFailedGoalP", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification")}), null);
Stella.defineFunctionObject("MARK-AS-CUTOFF-GOAL?", "(DEFUN (MARK-AS-CUTOFF-GOAL? BOOLEAN) ((SELF JUSTIFICATION)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "markAsCutoffGoalP", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification")}), null);
Stella.defineFunctionObject("PARTIALLY-FOLLOWS?", "(DEFUN (PARTIALLY-FOLLOWS? BOOLEAN) ((SELF JUSTIFICATION)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "partiallyFollowsP", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification")}), null);
Stella.defineFunctionObject("MAKE-RULE-ORIGIN-EXPLANATION-PHRASE", "(DEFUN (MAKE-RULE-ORIGIN-EXPLANATION-PHRASE STRING) ((SELF JUSTIFICATION)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "makeRuleOriginExplanationPhrase", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification")}), null);
Stella.defineFunctionObject("GET-EXPLANATION-SUBSTITUTION", "(DEFUN (GET-EXPLANATION-SUBSTITUTION ENTITY-MAPPING) ((SELF JUSTIFICATION)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "getExplanationSubstitution", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification")}), null);
Stella.defineFunctionObject("PRINT-ONE-VARIABLE-SUBSTITUTION", "(DEFUN PRINT-ONE-VARIABLE-SUBSTITUTION ((STREAM OUTPUT-STREAM) (VAR OBJECT) (VALUE OBJECT)))", Native.find_java_method("edu.isi.powerloom.logic.Logic", "printOneVariableSubstitution", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.OutputStream"), Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("edu.isi.stella.Stella_Object")}), null);
Stella.defineFunctionObject("PRINT-EXPLANATION-SUBSTITUTION", "(DEFUN PRINT-EXPLANATION-SUBSTITUTION ((SELF JUSTIFICATION) (STREAM OUTPUT-STREAM) (MAPPING EXPLANATION-MAPPING)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "printExplanationSubstitution", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification"), Native.find_java_class("edu.isi.stella.OutputStream"), Native.find_java_class("edu.isi.stella.KeyValueList")}), null);
Stella.defineFunctionObject("PRINT-EXPLANATION-ANTECEDENTS", "(DEFUN PRINT-EXPLANATION-ANTECEDENTS ((SELF JUSTIFICATION) (STREAM OUTPUT-STREAM) (MAPPING EXPLANATION-MAPPING) (MAXDEPTH INTEGER) (UNEXPLAINED (LIST OF JUSTIFICATION))))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "printExplanationAntecedents", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification"), Native.find_java_class("edu.isi.stella.OutputStream"), Native.find_java_class("edu.isi.stella.KeyValueList"), java.lang.Integer.TYPE, Native.find_java_class("edu.isi.stella.List")}), null);
Stella.defineFunctionObject("VISIBLE-JUSTIFICATION", "(DEFUN (VISIBLE-JUSTIFICATION JUSTIFICATION) ((SELF JUSTIFICATION)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "visibleJustification", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification")}), null);
Stella.defineFunctionObject("VISIBLE-ANTECEDENTS", "(DEFUN (VISIBLE-ANTECEDENTS (LIST OF JUSTIFICATION)) ((SELF JUSTIFICATION)))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "visibleAntecedents", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification")}), null);
Stella.defineFunctionObject("COLLECT-VISIBLE-ANTECEDENTS", "(DEFUN COLLECT-VISIBLE-ANTECEDENTS ((SELF JUSTIFICATION) (VISIBLEANTECEDENTS (LIST OF JUSTIFICATION))))", Native.find_java_method("edu.isi.powerloom.logic.Justification", "collectVisibleAntecedents", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Justification"), Native.find_java_class("edu.isi.stella.List")}), null);
Stella.defineFunctionObject("WHY", "(DEFUN WHY (|&REST| (ARGS OBJECT)) :PUBLIC? TRUE :COMMAND? TRUE :EVALUATE-ARGUMENTS? FALSE :DOCUMENTATION \"Print an explanation for the result of the most recent query.\nWithout any arguments, `why' prints an explanation of the top level\nquery proposition down to a maximum depth of 3. `(why all)' prints\nan explanation to unlimited depth. Alternatively, a particular depth\ncan be specified, for example, `(why 5)' explains down to a depth of 5.\nA proof step that was not explained explicitly (e.g., due to a depth\ncutoff) can be explained by supplying the label of the step as the\nfirst argument to `why', for example, `(why 1.2.3 5)' prints an explanation\nstarting at 1.2.3 down to a depth of 5 (which is counted relative to the\ndepth of the starting point). The keywords `brief' and `verbose' can be\nused to select a particular explanation style. In brief mode, explicitly\nasserted propositions are not further explained and indicated with a\n`!' assertion marker. Additionally, relatively uninteresting proof steps\nsuch as AND-introductions are skipped. This explanation style option is\nsticky and will affect future calls to `why' until it gets changed again.\nThe various options can be combined in any way, for example,\n`(why 1.2.3 brief 3)' explains starting from step 1.2.3 down to a depth\nof 3 in brief explanation mode.\")", Native.find_java_method("edu.isi.powerloom.logic.Logic", "why", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Cons")}), Native.find_java_method("edu.isi.powerloom.logic.Logic", "whyEvaluatorWrapper", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Cons")}));
Stella.defineFunctionObject("EXPLAIN-WHY", "(DEFUN EXPLAIN-WHY ((LABEL STRING) (STYLE KEYWORD) (MAXDEPTH INTEGER) (STREAM OUTPUT-STREAM)) :PUBLIC? TRUE :DOCUMENTATION \"Programmer's interface to WHY function.\")", Native.find_java_method("edu.isi.powerloom.logic.Logic", "explainWhy", new java.lang.Class [] {Native.find_java_class("java.lang.String"), Native.find_java_class("edu.isi.stella.Keyword"), java.lang.Integer.TYPE, Native.find_java_class("edu.isi.stella.OutputStream")}), null);
Stella.defineFunctionObject("EXPLAIN-PROPOSITION", "(DEFUN EXPLAIN-PROPOSITION ((PROP PROPOSITION) (STYLE KEYWORD) (MAXDEPTH INTEGER) (STREAM OUTPUT-STREAM)) :PUBLIC? TRUE :DOCUMENTATION \"Print an explanation for `prop' if there is one. This will only happen\nfor forward-chained propositions.\")", Native.find_java_method("edu.isi.powerloom.logic.Proposition", "explainProposition", new java.lang.Class [] {Native.find_java_class("edu.isi.powerloom.logic.Proposition"), Native.find_java_class("edu.isi.stella.Keyword"), java.lang.Integer.TYPE, Native.find_java_class("edu.isi.stella.OutputStream")}), null);
Stella.defineFunctionObject("GET-WHY-JUSTIFICATION", "(DEFUN (GET-WHY-JUSTIFICATION JUSTIFICATION) ((LABEL STRING)) :PUBLIC? TRUE :DOCUMENTATION \"Returns the current WHY justification. May also throw one of the\nfollowing subtypes of EXPLAIN-EXCEPTION:\n EXPLAIN-NO-QUERY-EXCEPTION\n EXPLAIN-NO-SOLUTION-EXCEPTION\n EXPLAIN-NO-MORE-SOLUTIONS-EXCEPTION\n EXPLAIN-NOT-ENABLED-EXCEPTION\n EXPLAIN-NO-SUCH-LABEL-EXCEPTION\n EXPLAIN-QUERY-TRUE-EXCEPTION\")", Native.find_java_method("edu.isi.powerloom.logic.Logic", "getWhyJustification", new java.lang.Class [] {Native.find_java_class("java.lang.String")}), null);
Stella.defineFunctionObject("COMMAND-OPTION-EQL?", "(DEFUN (COMMAND-OPTION-EQL? BOOLEAN) ((ARG OBJECT) (OPTION STRING)))", Native.find_java_method("edu.isi.powerloom.logic.Logic", "commandOptionEqlP", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Stella_Object"), Native.find_java_class("java.lang.String")}), null);
Stella.defineFunctionObject("PARSE-WHY-ARGUMENTS", "(DEFUN (PARSE-WHY-ARGUMENTS STRING KEYWORD INTEGER BOOLEAN) ((ARGS (CONS OF OBJECT))))", Native.find_java_method("edu.isi.powerloom.logic.Logic", "parseWhyArguments", new java.lang.Class [] {Native.find_java_class("edu.isi.stella.Cons"), Native.find_java_class("[Ljava.lang.Object;")}), null);
Stella.defineFunctionObject("STARTUP-EXPLANATIONS", "(DEFUN STARTUP-EXPLANATIONS () :PUBLIC? TRUE)", Native.find_java_method("edu.isi.powerloom.logic._StartupExplanations", "startupExplanations", new java.lang.Class [] {}), null);
{ MethodSlot function = Symbol.lookupFunction(Logic.SYM_LOGIC_STARTUP_EXPLANATIONS);
KeyValueList.setDynamicSlotValue(function.dynamicSlots, Logic.SYM_STELLA_METHOD_STARTUP_CLASSNAME, StringWrapper.wrapString("_StartupExplanations"), Stella.NULL_STRING_WRAPPER);
}
}
if (Stella.currentStartupTimePhaseP(8)) {
Stella.finalizeSlots();
Stella.cleanupUnfinalizedClasses();
}
if (Stella.currentStartupTimePhaseP(9)) {
Stella_Object.inModule(((StringWrapper)(Stella_Object.copyConsTree(StringWrapper.wrapString("LOGIC")))));
Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFSPECIAL *EXPLANATION-FORMAT* KEYWORD :ASCII :DOCUMENTATION \"Keyword to control the explanation format.\nValid values are :ASCII, :HTML and :XML\")");
Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFSPECIAL *EXPLANATION-STYLE* KEYWORD :BRIEF :DOCUMENTATION \"Keywords that controls how detailed explanations will be.\nValid values are :VERBOSE and :BRIEF.\" :PUBLIC? TRUE)");
Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFSPECIAL *EXPLANATION-AUDIENCE* KEYWORD :TECHNICAL :DOCUMENTATION \"Keywords that controls the language for justifications.\nValid values are :TECHNICAL and :LAY\" :PUBLIC? TRUE)");
Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *DEFAULT-EXPLANATION-DEPTH* INTEGER 3 :DOCUMENTATION \"Maximal explanation depth used if not otherwise specified.\" :PUBLIC? TRUE)");
Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *EXPLANATION-TAB-STRING* STRING \" \")");
Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *MAX-INLINE-LABEL-LENGTH* INTEGER 10 :DOCUMENTATION \"Maximum length of a label string for which the following\nproposition will be printed on the same line.\")");
Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *EXPLANATION-ASSERTION-MARKER* STRING \"!\")");
Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *EXPLANATION-FAILURE-MARKER* STRING \"?\")");
Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *EXPLANATION-CUTOFF-MARKER* STRING \"x\")");
Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *EXPLANATION-INFERENCE-MARKER* STRING \" \")");
Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFSPECIAL *EXPLANATION-VOCABULARY* EXPLANATION-VOCABULARY NULL :DOCUMENTATION \"The currently active vocabulary lookup table\")");
Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFGLOBAL *EXPLANATION-VOCABULARIES* (KEY-VALUE-LIST OF KEYWORD EXPLANATION-VOCABULARY) (NEW KEY-VALUE-LIST) :DOCUMENTATION \"List of vocabularies with keyword keys\")");
Logic.defineExplanationPhrase(Logic.KWD_UNKNOWN_RULE, Logic.KWD_TECHNICAL, "because of an inference PowerLoom can't explain yet", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_FOLLOWS, Logic.KWD_TECHNICAL, "follows", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_FOLLOWS, Logic.KWD_LAY, "is true", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_FOLLOWS, Logic.KWD_TECHNICAL, "is partially true", Cons.cons(Logic.KWD_PARTIAL, Stella.NIL));
Logic.defineExplanationPhrase(Logic.KWD_FOLLOWS, Logic.KWD_LAY, "is true to some part", Cons.cons(Logic.KWD_PARTIAL, Stella.NIL));
Logic.defineExplanationPhrase(Logic.KWD_HOLDS, Logic.KWD_TECHNICAL, "holds", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_HOLDS, Logic.KWD_LAY, "is true", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_DEFINITION, Logic.KWD_TECHNICAL, "by the definition of", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_DEFINITION, Logic.KWD_LAY, "by the definition of", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_FAILED, Logic.KWD_TECHNICAL, "failed", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_FAILED, Logic.KWD_LAY, "could not be proven", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_INCONSISTENT, Logic.KWD_TECHNICAL, "is inconsistent", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_INCONSISTENT, Logic.KWD_LAY, "has a contradiction", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_CLASH, Logic.KWD_TECHNICAL, "because it and its negation were inferred", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_CLASH, Logic.KWD_LAY, "because opposite conclusions were reached", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_NOT_ASSERTED, Logic.KWD_TECHNICAL, "is not asserted", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_NOT_ASSERTED, Logic.KWD_LAY, "is not asserted to be true", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_NO_RULES, Logic.KWD_TECHNICAL, "no potential inference leading to the proposition could be found", Stella.NIL);
Logic.defineExplanationPhrase(Logic.KWD_NO_RULES, Logic.KWD_LAY, "no rules for proving the proposition could be found", Stella.NIL);
Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFSPECIAL *CURRENTJUSTIFICATION* JUSTIFICATION NULL)");
Stella.defineStellaGlobalVariableFromStringifiedSource("(DEFSPECIAL *MOST-RECENT-EXPLANATION-MAPPING* EXPLANATION-MAPPING NULL)");
}
} finally {
Stella.$CONTEXT$.set(old$Context$000);
Stella.$MODULE$.set(old$Module$000);
}
}
} |
1765a02b-eb2f-4205-ae9a-1f0831bd1b15 | 2 | public int setCurrent(Piece piece, int x, int y) {
int result = board.place(piece, x, y);
if (result <= Board.PLACE_ROW_FILLED) { // SUCESS
// repaint the rect where it used to be
if (currentPiece != null) repaintPiece(currentPiece, currentX, currentY);
currentPiece = piece;
currentX = x;
currentY = y;
// repaint the rect where it is now
repaintPiece(currentPiece, currentX, currentY);
}
else {
board.undo();
}
return(result);
} |
2e7ff77d-0406-4101-a1b7-98eda775fc5d | 6 | public void visit(
final int version,
final int access,
final String name,
final String signature,
final String superName,
final String[] interfaces)
{
StringBuffer sb = new StringBuffer();
appendAccess(access | ACCESS_CLASS, sb);
AttributesImpl att = new AttributesImpl();
att.addAttribute("", "access", "access", "", sb.toString());
if (name != null) {
att.addAttribute("", "name", "name", "", name);
}
if (signature != null) {
att.addAttribute("",
"signature",
"signature",
"",
encode(signature));
}
if (superName != null) {
att.addAttribute("", "parent", "parent", "", superName);
}
att.addAttribute("",
"major",
"major",
"",
Integer.toString(version & 0xFFFF));
att.addAttribute("",
"minor",
"minor",
"",
Integer.toString(version >>> 16));
addStart("class", att);
addStart("interfaces", new AttributesImpl());
if (interfaces != null && interfaces.length > 0) {
for (int i = 0; i < interfaces.length; i++) {
AttributesImpl att2 = new AttributesImpl();
att2.addAttribute("", "name", "name", "", interfaces[i]);
addElement("interface", att2);
}
}
addEnd("interfaces");
} |
d3483ee0-7ca1-44b4-8dc5-cb623106f677 | 6 | @SuppressWarnings("unchecked")
public Object newMetadata() {
if (modelData.containsKey(id)) {
Object model = modelData.get(id);
Object w;
try {
w = DynamicClassFunctions.classes.get("DataWatcher").newInstance();
} catch (Exception e) {
DisguiseCraft.logger.log(Level.SEVERE, "Could not construct a new DataWatcher to insert values into", e);
return null;
}
// Clone Map
try {
HashMap<Integer, Object> modelMap = ((HashMap<Integer, Object>) mapField.get(model));
HashMap<Integer, Object> newMap = ((HashMap<Integer, Object>) mapField.get(w));
for (Integer index : modelMap.keySet()) {
newMap.put(index, copyWatchable(modelMap.get(index)));
}
} catch (Exception e) {
DisguiseCraft.logger.log(Level.SEVERE, "Could not clone map in a " + this.name() + "'s model datawatcher!");
}
// Clone boolean
try {
boolField.setBoolean(w, boolField.getBoolean(model));
} catch (Exception e) {
DisguiseCraft.logger.log(Level.SEVERE, "Could not clone boolean in a " + this.name() + "'s model datawatcher!");
}
return w;
} else {
try {
return DynamicClassFunctions.classes.get("DataWatcher").newInstance();
} catch (Exception e) {
DisguiseCraft.logger.log(Level.SEVERE, "Could not construct a new DataWatcher", e);
return null;
}
}
} |
2cdc0c90-e227-49db-abac-bfa68971e530 | 5 | public static boolean getBoolean(Object value) {
try {
String v = getString(value);
if ("1".equals(v)) {
return true;
} else if ("0".equals(v)) {
return false;
} else if ("Y".equals(v)) {
return true;
} else if ("N".equals(v)) {
return false;
} else {
return Boolean.parseBoolean(v);
}
} catch (Exception e) {
return false;
}
} |
c59c912e-6c5b-4434-8171-5f0104eb3f27 | 3 | public int getSum() {
aapneForbindelse();
double sum = 0;
int okter = -1;
try {
setning = forbindelse.prepareStatement(sqlGetSum);
setning.setString(1, brukernavn);
res = setning.executeQuery();
while (res.next()) {
sum = res.getDouble(1);
okter = res.getInt(2);
}
} catch (SQLException e) {
Opprydder.skrivMelding(e,"getSum()");
} finally {
Opprydder.lukkSetning(setning);
stengForbindelse();
}
if (okter != 0) {
return (int) sum / okter;
} else {
return 0;
}
} |
08ba7c73-85dd-47e2-a94a-ffc8932f967a | 4 | public JSONObject toJSONObject(JSONArray names) throws JSONException {
if (names == null || names.length() == 0 || this.length() == 0) {
return null;
}
JSONObject jo = new JSONObject();
for (int i = 0; i < names.length(); i += 1) {
jo.put(names.getString(i), this.opt(i));
}
return jo;
} |
9e70abf1-9258-454b-85d6-614f06cde387 | 7 | @EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void rates(CreatureSpawnEvent event)
{
if (P.p().shouldIgnoreNextSpawn() || P.p().shouldAbilitiesIgnoreNextSpawn())
return;
if (!P.p().getPluginIntegration().canApplyAbilities(event.getEntity()))
{
P.p().abilitiesIgnoreNextSpawn(true);
return;
}
MobAbilityConfig ma = AbilityConfig.i().getMobConfig(event.getLocation().getWorld().getName(), ExtendedEntityType.valueOf(event.getEntity()), event.getSpawnReason());
if (ma == null)
return;
if (ma.spawnRate < 1.0)
{
if (ma.spawnRate == 0.0)
{
event.setCancelled(true);
return;
}
// If the random number is higher than the spawn chance we disallow the spawn
if (RandomUtil.i.nextFloat() >= ma.spawnRate)
{
event.setCancelled(true);
return;
}
}
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.