text stringlengths 14 410k | label int32 0 9 |
|---|---|
private final void encode(final ByteArrayBuffer fb, final char c) {
if (c < 0x80) {
fb.append((byte) c);
} else if (c < 0x800) {
fb.append((byte) (0xc0 | c >> 6));
fb.append((byte) (0x80 | c & 0x3f));
} else if(c < 0xD800){
fb.append((byte) (0xe0 |... | 7 |
@Override
public String toString() {
StringBuffer info = new StringBuffer();
info.append("Layer Name :: ").append(getName()).append("\n");
info.append("logical Queue : ").append(logicalQueue).append("\n");
info.append("Draw List : ").append(drawableList);
// Output drawable
info.append(drawableList.size()... | 2 |
private void load() {
String packageName = "Exercises";
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
ArrayList<String> names = new ArrayList<String>();
URL packageURL = classLoader.getResource(packageName);
if (packageURL != null) {
File folder = new File(packageURL.getFile().r... | 9 |
public void adjustRGB(int adjustmentR, int adjustmentG, int adjustmentB) {
for (int pixel = 0; pixel < pixels.length; pixel++) {
int originalColour = pixels[pixel];
if (originalColour != 0) {
int red = originalColour >> 16 & 0xff;
red += adjustmentR;
if (red < 1)
red = 1;
else if (red > 255... | 8 |
private void reloadMode(ModeEnum myMode) {
String[] modes = comboMode.getItems();
String label = myMode.getLabel();
for (int index = 0; index < modes.length; index++) {
if (label.equals(modes[index])) {
comboMode.select(index);
break;
}
... | 2 |
private void dessineCamembert(Noeud n, Graphics g,
HashMap<String, Color[]> historique, DrawStrategy strategy,
Color couleur_demande) {
// on dessine le noeud de destination
// differement selon la strategie defini
if (strategy == DrawStrategy.LAST_WIN) {
// Si la strategy est LAST_WIN, il suffit
// d... | 8 |
public int getInt() {
String textv = ((TextEntry)wdg()).text;
try{
Integer ival = Integer.parseInt(textv);
return ival.intValue();
}
catch(NumberFormatException e){
return 0;
}
} | 1 |
public static void filledRectangle(double x, double y, double halfWidth, double halfHeight) {
if (halfWidth < 0) throw new IllegalArgumentException("half width must be nonnegative");
if (halfHeight < 0) throw new IllegalArgumentException("half height must be nonnegative");
double xs = scaleX(x)... | 4 |
public String execute() {
return "SUCCESS";
} | 0 |
public Connection(Socket socket) throws java.io.IOException{
this.socket = socket;
if (socket!=null) {
setInputStream(socket.getInputStream());
setOutputStream(socket.getOutputStream());
}
} | 1 |
protected static String processEmphasis(String text) {
String[] arr = text.split("\\|");
if (arr.length == 2) {
return "<span class=\"emphasis\">" + arr[1] + "</span>";
}
return "<span class=\"emphasis\">" + arr[1] + "</span><span class=\"afterEmphasis\">" + arr[2] + "</span>... | 1 |
Power(String name, int properties, String imgFile, String helpInfo) {
this.name = name ;
this.helpInfo = helpInfo ;
this.buttonTex = Texture.loadTexture(IMG_DIR+imgFile) ;
this.properties = properties ;
} | 7 |
public int swapOddAndEvenBit(int origNum){
int resultNum = 0;
//make a new Num with origNum shift right by 1;
System.out.println("origNum="+origNum);
int shiftedNum = origNum >> 1;
System.out.println("shiftedRight="+shiftedNum);
//XOR origNum and shiftedNum, then bit 0 would be XOR of bit(0,1), bit 1 =... | 2 |
public boolean hasIntArg() {
try{
String s = peek();
if(s.isEmpty()) {
return false;
} else {
Integer.valueOf(s);
}
} catch(NumberFormatException e) {
return false;
}
return true;
} | 2 |
public IVPNumber divide(IVPNumber number, Context context, DataFactory factory, HashMap map) {
IVPNumber result = factory.createIVPNumber();
map.put(result.getUniqueID(), result);
if(getValueType().equals(IVPValue.INTEGER_TYPE) && number.getValueType().equals(IVPValue.INTEGER_TYPE)){
int resultInt = context.ge... | 5 |
public static Direction flip_x_dir(Direction d) {
switch (d) {
case NW:
return NE;
case W:
return E;
case SW:
return SE;
case N:
return N;
case S:
return S;
cas... | 8 |
public void copyAsRtf() {
int selStart = getSelectionStart();
int selEnd = getSelectionEnd();
if (selStart==selEnd) {
return;
}
// Make sure there is a system clipboard, and that we can write
// to it.
SecurityManager sm = System.getSecurityManager();
if (sm!=null) {
try {
sm.checkSystemClip... | 9 |
public void setCode_sec(String code_sec) {
this.code_sec = code_sec;
} | 0 |
@Override
public void mouseReleased(MouseEvent event) {
if (mSortColumn != null) {
if (mSortColumn == mOwner.overColumn(event.getX())) {
if (mOwner.isUserSortable()) {
boolean sortAscending = mSortColumn.isSortAscending();
if (mSortColumn.getSortSequence() != -1) {
sortAscending = !sortAscendi... | 4 |
public boolean contains(Point p) {
Point p0 = this.getXY();
int s2 = this.getParent().getConnectorSize() / 2;
return (p.x >= p0.x - s2 && p.x <= p0.x + s2 && p.y >= p0.y - s2 && p.y <= p0.y
+ s2);
} | 3 |
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://down... | 6 |
public static void add(Record rec, User user, int score) throws SQLException
{
if (rec != null && user != null)
{
String sql = "INSERT INTO score_history (record_id,user_id,score_date,score_value) VALUES (?,?,now(),?)";
PreparedStatement ps = Connect.getConnection().getPreparedStatemen... | 2 |
public Boolean isWellFormed(String strParentheses) {
if (strParentheses == null) {
return false;
}
// Idea is to have two counters, one for open parentheses '{' and one
// for close '}'
// Read one character at a time and increment one of the counters
// If any given point of time count of close parenthe... | 6 |
protected Batch <String> descOngoingUpgrades() {
final Batch <String> desc = new Batch <String> () ;
if (upgrades == null) return desc ;
for (int i = 0 ; i < upgrades.length ; i++) {
if (upgrades[i] == null || upgradeStates[i] == STATE_INTACT) continue ;
desc.add(upgrades[i].name+" ("+STATE_DESC... | 4 |
* @param mes the messsage
*/
private void handleMONOPOLYPICK(StringConnection c, MonopolyPick mes)
{
if (c != null)
{
Game ga = gameList.getGameData(mes.getGame());
if (ga != null)
{
ga.takeMonitor();
try
... | 9 |
public static void renderButton(Graphics g, Rectangle r, String s)
{
if(r.contains(Main.mse))
{
g.drawImage(Button2, r.x, r.y, r.width, r.height, null);
}
else
{
g.drawImage(Button1, r.x, r.y, r.width, r.height, null);
}
g.setFont(new Font(Font.SANS_SERIF, (int)(r.height/1.75), (int)(r.height/1.75)... | 1 |
public void setAttribute(String asName, String asVal, boolean abMultiAttr) {
if (UtilityMethods.isValidString(asName) && UtilityMethods.isValidString(asName)) {
if (abMultiAttr) {
getAttrList().add(new Attribute(asName, asVal));
} else {
Attribute laAttr =... | 4 |
public static void main(String[] args) {
ShopifyService service = new ShopifyService();
String url ="https://0f99730e50a2493463d263f6f6003622:1a27610dee9600dd8366bf76d90b5589@shopatmyspace.myshopify.com/admin/customers.json";
try{
final HttpClientContext context = HttpClientContext.create();
Closeable... | 2 |
protected void landingOn(PlayerClass pPlayer)
{
this.victim = pPlayer;
if(this.owned == true && this.currentOwner == pPlayer && ownsAllColours() == true) // If you own your own property, you can upgrade.
{
buyMenu();
}
if(this.owned == false && pPlayer.account.getBalance() >= this.buyPrice) // If not owned,... | 7 |
@Override
public void setSelected( Selection selection ) {
super.setSelected( selection );
connection.updateSelection();
ItemSelectionEvent event = new ItemSelectionEvent( connection, selection );
for( ItemSelectionListener listener : listeners()){
listener.itemSelectionChanged( event );
}
} | 1 |
private String options() {
String options = "";
int commandNumber = 1;
for (Command command : commands){
options += commandNumber++ + ") " + command.name() + "\n";
}
return options;
} | 1 |
public Object nextValue() throws JSONException {
char c = this.nextClean();
String string;
switch (c) {
case '"':
case '\'':
return this.nextString(c);
case '{':
this.back();
return new JSONObject(this);
... | 7 |
@Override
public String toString() {
String result = "[";
int i = 0;
while (i < capacity) {
if (queue[i] != null) {
result += queue[i] + ", ";
}
i++;
}
if (result.length() > 2) {
result = result.substring(0, result.length() - 2);
}
result += "]";
return result;
} | 3 |
public static void createIcons() {
// Create a buffered image from the is not property image.
Image isNotPropertyImage = ICON_IS_NOT_PROPERTY.getImage();
BufferedImage isNotImage = new BufferedImage(TRUE_WIDTH, BUTTON_HEIGHT, BufferedImage.TYPE_INT_ARGB);
Graphics2D gIsNotImage = isNotImage.createGraphics();
... | 0 |
private final static long getDays(long year) {
final Long entry = Time.daysSince1970.get(year);
if (entry != null) {
return entry;
}
long days = 0;
for (long y = 1970; y < year; ++y) {
final boolean leap = isLeap(y);
if (leap) {
days += 366;
} else {
days += 365;
}
}
Time.daysSince1... | 3 |
protected CoderResult decodeLoop(ByteBuffer in, CharBuffer out) {
CoderResult result;
while (true) {
// output buffered data
if (buf.hasRemaining()) {
result = super.decodeLoop(buf,out);
// stop if out of output space or err... | 5 |
protected void pasteBufferedComponent(int x, int y) {
if (pasteBuffer instanceof ImageComponent) {
ImageComponent ic = null;
try {
ic = new ImageComponent(((ImageComponent) pasteBuffer).toString());
} catch (Exception e) {
e.printStackTrace();
return;
}
ic.setLocation(x, y);
addLayeredCo... | 8 |
public void actionPerformed(ActionEvent e) {
this.setCmd(e.getActionCommand());
if (isCmd("debugmode")) {
if (this.getInfo().chckbxDebug.isSelected()) {
this.getCore().settings.set(this.getCore().showDebug, "true");
} else {
this.getCore().settings.set(this.getCore().showDebug, "false");
}
... | 7 |
public void loadMapFromFile(File selFile) {
BufferedReader csvReader = null;
try {
csvReader = new BufferedReader(new FileReader(selFile));
} catch (FileNotFoundException ex) {
ex.printStackTrace();
}
int fieldCount = 0;
int lineCount = 0;
... | 6 |
@Override
public double getWidth() {
double width = 0;
double x = getX();
double temp = 0;
ModelSubset[] subs = getAnimatedModel().getSubsets();
for (int i = 0; i < subs.length; i++) {
for (int j = 0; j < subs[i].getVertices().length; j++) {
temp = subs[i].getVertices()[j].getX() - x;
Math.abs(tem... | 3 |
private synchronized IndexReader doReopenNoWriter(final boolean openReadOnly, IndexCommit commit) throws CorruptIndexException, IOException {
if (commit == null) {
if (hasChanges) {
// We have changes, which means we are not readOnly:
assert readOnly == false;
// and we hold the write... | 9 |
public synchronized void write(Transaction ta, int pageId, String data) {
incrementLSN();
// write the data to a file
// one file for each page
// LSN also into the file for redoing
log(ta.getTaId(), LogType.WRITE, pageId, data);
Page page = new Page(pageId, logSequenceNumber, data, ta);
buffer.put(pa... | 3 |
private static void insertionSort(int[] arr) {
if(arr.length < 2) return;
int firstUnsortedNum;//第一个未排序的数,我们认为arr[0]已经排好序,因而从arr[1]开始
for(int i=1; i<arr.length; i++){
firstUnsortedNum = arr[i];
int j = i - 1;
while(j>=0 && firstUnsortedNum < arr[j]){//和已排好序的数进行比较,从最后一个已排序数开始
arr[j+1] = arr[j];
... | 4 |
public boolean supprimerLocation(int numero){
System.out.println("ModeleLocations::supprimerLocation()") ;
Location location = rechercherLocation(numero) ;
if(location != null){
location.getVehicule().setSituation(Vehicule.DISPONIBLE) ;
this.locations.remove(location) ;
return true ;
}
else {
retu... | 1 |
public boolean connect (String IP, boolean scan)
{
try
{
if(scan){
socket = findServer();
if(socket == null){
jTextField2.setText("Status: No Server Found");
return false;
}
... | 4 |
public void newProject() throws IOException {
boolean canceled = false;
if (isChanged) {
Object[] options = { Tools.getLocalizedString("YES"),
Tools.getLocalizedString("NO") };
JFrame frame = new JFrame();
int n = JOptionPane.showOptionDialog(frame,
Tools.getLocalizedString("EXIT_DIALOGUE"),
... | 4 |
@Override
public void e(float sideMot, float forMot) {
if (this.passenger == null || !(this.passenger instanceof EntityHuman)) {
super.e(sideMot, forMot);
this.W = 0.5F; // Make sure the entity can walk over half slabs,
// instead of jumping
return;
}
EntityHuman human = (EntityHuman) this.passe... | 8 |
public static Coordinates readMoveFromKeyboard() {
Coordinates result = null;
while (result == null) {
System.out.print(">");
String str = null;
int row = 0, column = 0;
BufferedReader d = new BufferedReader(new InputStreamReader(
Syst... | 8 |
public int getValue() {
int status = 0;
status |= (negative ? 0x80 : 0);
status |= (overflow ? 0x40 : 0);
status |= (memory_access ? 0x20 : 0);
status |= (index_register ? 0x10 : 0);
status |= (decimal_mode ? 0x8 : 0);
status |= (irq_disable ? 0x4 : 0);
status |= (zero ? 0x2 : 0);
status |= (carry ? 0... | 8 |
protected void actionPerformed(GuiButton par1GuiButton)
{
if (!par1GuiButton.enabled)
{
return;
}
if (par1GuiButton.id == 2)
{
String s = getSaveName(selectedWorld);
if (s != null)
{
deleting = true;
... | 7 |
private static boolean
classMatcher(REGlobalData gData, RECharSet charSet, char ch)
{
if (!charSet.converted) {
processCharSet(gData, charSet);
}
int byteIndex = ch / 8;
if (charSet.sense) {
if ((charSet.length == 0) ||
( (ch > charSet.le... | 8 |
@Override
public boolean getUserExists(String username) {
boolean userExists = false;
// Find an user record in the entity bean User, passing a primary key of
// username.
User user = emgr.find(entity.User.class, username);
// Determine whether the user exists
if (user != null) {
userExists = true;
... | 1 |
public boolean equals(Object passedObj)
{
//Checks if the object exists
if (passedObj == null)
{
return false;
}
//Checks to ensure the class is an instance of this class
if(!(passedObj instanceof MyAllTypesSecond))
{
return false;
}
if(passedObj == this)
{
return true;
}
MyAllTy... | 8 |
@Override
public ArrayList<seed> move(ArrayList<Pair> initTreelist, double initWidth, double initLength, double initS) {
treelist = initTreelist;
width = initWidth;
length = initLength;
s = initS;
seedgraph = new SeedGraph(initTreelist, initWidth, initLength, initS);
boards = new Boards(seedgraph);
Arra... | 8 |
@Override
public final boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof OCPTelno)) {
return false;
}
OCPTelno other = (OCPTelno) obj;
if (!A... | 5 |
public void refreshGameControl() {
// mortgageOption
gamecontrol.optionPanel.removeAll();
int y=50;
if (showThrowDiceBtn) {
// Insert dice button
JButton copy = choices.get(0);
copy.setSize(gamecontrol.optionPanel.getWidth(),50);
c... | 9 |
public static void main(String[] args) {
// -------------------------Initialize Job Information------------------------------------
/*********************************Big Experiments*********************************/
//String startJobId = "job_201301181454_0001";
//String jobName = "Big-uservisits_aggre-pig-5... | 4 |
public Pelaaja() {
super(0, 0);
xNopeus = 0;
xSuunta = 0;
isoHyppy = 0;
putoamiskiihtyvyysPerFrame = 1;
terminaalinopeus = 50;
/**
* Nopeudeksi määritetään terminaalinopeus, koska jos pelaaja alottaa
* ilmasta, haluamme sen putoavan täysiiiiiii
... | 0 |
String getHelpText() {
boolean letters = ((characters & LETTERS) == LETTERS);
boolean digits = ((characters & DIGITS) == DIGITS);
boolean ascii = ((characters & SYMBOL) == SYMBOL);
return "Allowed characters:"
+ (letters ? " letters" : " ")
+ (digits ? " digits" : " ")
+ (ascii ? " ascii" : " ")
... | 5 |
public void addPart3(Statement statement, String line) {
String counterPartyAccount = line.substring(10, 44).trim();
CounterParty counterParty = new CounterParty();
if (!counterPartyAccount.trim().equals("")) {
BankAccount bankAccount = new BankAccount(counterPartyAccount);
... | 3 |
private void jCheckBoxComptesRendusActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxComptesRendusActionPerformed
//Récupération de la méthode contrôleur 'afficherComptesRendus'
this.getCtrlM().afficherComptesRendus();
}//GEN-LAST:event_jCheckBoxComptesRendusActionPerformed | 0 |
private void addUniform(String uniformName, String uniformType, HashMap<String, ArrayList<GLSLStruct>> structs) {
boolean addThis = true;
ArrayList<GLSLStruct> structComponents = structs.get(uniformType);
if (structComponents != null) {
addThis = false;
for (GLSLStruct ... | 3 |
public ArrayList<String> getRequirementString() {
ArrayList<String> requirements = new ArrayList<String>();
if(!item1.equals("None")) {
requirements.add(item1 + ":" + item1Qty);
}
if(!item2.equals("None")) {
requirements.add(item2 + ":" + item2Qty);
... | 5 |
public List<Disciplina> getDisciplinasPreferidasComNivel(
int nivelPreferencia) throws PreferenciaInvalidaException {
switch (nivelPreferencia) {
case 1:
return this.listaDisciplinasP1;
case 2:
return this.listaDisciplinasP2;
case 3:
return this.listaDisciplinasP3;
case 4:
return this.listaDisc... | 4 |
public void update(Contestant c) throws InvalidFieldException {
if (c.getFirstName() != null) {
setFirstName(c.getFirstName());
}
if (c.getLastName() != null) {
setLastName(c.getLastName());
}
if (c.getID() != null) {
setID(c.getID());
}
if (c.getPicture() != null) {
setPicture(c.getPicture... | 6 |
public static boolean deleteFile(Path file) {
boolean ret = false;
if ((file != null) && Files.exists(file, LinkOption.NOFOLLOW_LINKS)) {
try {
if (file.toFile().canWrite()) {
Files.delete(file);
}
ret = !Files.exists(file,... | 4 |
public TroubleInputStream(InputStream in, Filter[] filters) {
super(in);
this.filters = filters;
hasFilters = filters != null && filters.length > 0;
} | 1 |
public void makeDeclaration(Set done) {
super.makeDeclaration(done);
/*
* Normally we have to declare our exceptionLocal. This is automatically
* done in dumpSource.
*
* If we are unlucky the exceptionLocal is used outside of this block.
* In that case we do a transformation.
*/
if (exceptionLo... | 4 |
public Main() {
movingObjects = new LinkedList<MovingObject>();
units = new LinkedList<Unit>();
units.add(new Summoner(50, 50));
units.add(new Summoner(100, 100));
units.add(new Collector(200, 50));
units.add(new Collector(200, 100));
buildings = new LinkedList<Building>();
buildings.add(new ManaA... | 1 |
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
ProcessManager other = (ProcessManager) obj;
if ... | 6 |
boolean validWallSet(boolean[][] w) {
// copy array
boolean[][] c;
c = new boolean[w.length][w[0].length];
for (int i=0; i<w.length; i++) {
for (int j=0; j<w[0].length; j++) c[i][j] = w[i][j];
}
// fill all 8-connected neighbours of the first empty
// square.
boolean found = false;
search: fo... | 9 |
private ArrayList<Language> sortProbability(double[] prob) {
ArrayList<Language> list = new ArrayList<Language>();
for(int j=0;j<prob.length;++j) {
double p = prob[j];
if (p > PROB_THRESHOLD) {
for (int i = 0; i <= list.size(); ++i) {
if (i == ... | 5 |
public void handleControl(ucEvent e){
if(e.getSource() == castor.source){
switch(e.getCommand()){
case 3: setMouseAction("Mirsel"); prisec = true; mirrefflag[1] = 0; break;
case 4: mirrefflag[1] = 1; prisec = true; setMouseAction("Mirsel");break;
}
}
if(e.getSource() == pollux.source){
switch(e.getComma... | 6 |
public static void toggleMoveableInheritanceText(Node currentNode, JoeTree tree, OutlineLayoutManager layout) {
CompoundUndoablePropertyChange undoable = new CompoundUndoablePropertyChange(tree);
toggleMoveableInheritanceForSingleNode(currentNode, undoable);
if (!undoable.isEmpty()) {
undoable.setName("Toggle... | 1 |
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
Function1 function1 = new Function1();
Function2 function2 = new Function2();
Function3 function3 = new Function3();
Function4 function4 = new Function4();
Function5 function5 = new Function5();
Function6 function6 = new F... | 9 |
private void drawMarking(Graphics2D g2) {
float yMarkingHeight = (getSize().height - (topMargin + bottomMargin)) / (float)yMarkCount;
int baseLineIndex = yMarkCount / 2;
int startY = topMargin;
double delta = (plotMaxY - plotMinY) / yMarkCount;
g2.setFont(fontLabel);
... | 8 |
public boolean checkHypergeometricParams(int k, int N, int D, int n) {
if ((k < 0) || (N < 0) || (D < 0) || (n < 0)) return false;
/* Change of variables
* drawn not drawn | total
* defective a = k b = D - k | D
* nondefective c = n - k d = N + k - n - D | N - D
* ----------------------... | 9 |
protected void drawRadarPoly(Graphics2D g2,
Rectangle2D plotArea,
Point2D centre,
PlotRenderingInfo info,
int series, int catCount,
double headH, double h... | 8 |
public static String colorizeParameter5(int param) {
String color = "";
if(param <= 15) color = "red";
if(param > 15 && param <= 30) color = "yellow";
if(param > 30 && param <= 70) color = "green";
if(param > 70 && param <= 85) color = "purple";
if(param > 85) co... | 8 |
protected void onDeathUpdate()
{
++this.deathTime;
if (this.deathTime == 20)
{
int var1;
if (!this.worldObj.isRemote && (this.recentlyHit > 0 || this.isPlayer()) && !this.isChild())
{
var1 = this.getExperiencePoints(this.attackingPlayer);... | 7 |
public void testCaddie (Connection conn) throws IOException, BDException {
if (session.getAttribute("config") == null) {
char d = BDRequetes.getTypeCaddie(conn);
if (d == 'P'){
BDRequetes.checkCaddieLifetime(conn);
session.setAttribute("config", "P");
}
else {
int d2 = BDRequetes.get... | 4 |
private UrlSource() {
this.urlList = new LinkedList<>();
try (
InputStream urlStream = this.getClass().getResourceAsStream("URLSET.txt");
BufferedReader urlReader = new BufferedReader(new InputStreamReader(urlStream));) {
String url;
while (true) {... | 4 |
public static ArrayList<Point> graham(ArrayList<Point> points) {
ArrayList<Point> bestPoints = new ArrayList<Point>();
Point tP = points.get(closestPoint(points));
points.remove(closestPoint(points));
sort(points, tP);
points.add(0, tP);
ArrayList<Point> uniqArray = new ... | 6 |
public void determinecounter(int grade) {
switch (grade / 10) {
case 10:
case 9:
acount++;
break;
case 8:
bcount++;
break;
case 7:
ccount++;
break;
case 6:
dcount++;
break;
default:
fcount++;
break;
}
} | 5 |
@Override
public void parse() throws IllegalArgumentException
{
try
{
setEncoding(Encoding.getEncoding(buffer[0]));
}
catch (IllegalArgumentException ex)
{ // ignore the bad value and set it to ISO-8859-1 so we can continue parsing the tag
setEncoding(Encoding.ISO_... | 3 |
@Test
public void testConstructor_IllegalArgumentException() {
boolean exceptionThrown = false;
try {
new PaymentResponse(null, 1, ServerResponseStatus.SUCCESS, null, "buyer", "seller", Currency.BTC, 12, System.currentTimeMillis());
} catch (IllegalArgumentException e) {
exceptionThrown = true;
}
asse... | 9 |
public static Direction getReversed(Direction d) {
switch (d) {
case DOWN:
return UP;
case DOWNLEFT:
return UPRIGHT;
case DOWNRIGHT:
return UPLEFT;
case LEFT:
return RIGHT;
case RIGHT:
return LEFT;
case UP:
return DOWN;
case UPLEFT:
return DOWNRIGHT;
case UPRIGHT:
... | 9 |
static public Calendar interpret(String value)
{
if(igpp.util.Text.isEmpty(value)) return null;
if(value.indexOf("-") != -1) return parse(value, CONVENTION); // Treat as convention format
// Intrept unitized values
Calendar time = getNow();
String[] part = value.split(" ", 2);
if(part.length < ... | 9 |
public JPopupMenu getMenu() {
if (elm == null) {
return null;
}
if (elm instanceof TransistorElm) {
scopeIbMenuItem.setState(value == VAL_IB);
scopeIcMenuItem.setState(value == VAL_IC);
scopeIeMenuItem.setState(value == VAL_IE);
scopeVb... | 7 |
@SuppressWarnings("unchecked")
public boolean equals(Object o){
if(o == null) return false;
if(o.getClass() == getClass()){
ShareableHashSet<V> other = (ShareableHashSet<V>) o;
if(other.currentHashCode != currentHashCode) return false;
if(other.size() != size()) return false;
if(isEmpty()) r... | 7 |
@Override
public String getColumnName(int column) {
return this.columnNames[column];
} | 0 |
public static long[] getPrimeSmallerThanK(int k, boolean print) {
long[] primes = new long[k];
primes[0] = 2;
int currPrimeCount = 1;
for(int i=3;i<=k;i+=2) { // even number cannot be prime
boolean isPrime = true;
long sqrt = (long) Math.sqrt(i);
for(int j=0; j<currPrimeCount && primes[j]<=s... | 6 |
public long getAllPopulation() {
long returnedPopulation = 0;
for (AstronomicalObject astronomicalObject : elements) {
if ((astronomicalObject.getClass() == InhabitedPlanet.class) || (astronomicalObject.getClass() == NaturalSatellite.class)) {
returnedPopulation += astronomic... | 3 |
@SuppressWarnings("unchecked")
@Test public void fuzzyTest() {
final Random rng = new Random(42);
for(int n = 0; n < 1000; n++) {
for(int k = 0; k < 100; k++) {
final int l = rng.nextInt(n + 1), r = n - l;
A a1 = emptyArray(), b1 = emptyArray();
final ArrayList<Integer> a2 = new... | 5 |
void initTranstoForm()
{
textInput.setText(getCommaStringFromArrayList(sim.getAlphabetFromTransitions()));
AutoCompleteComboBoxModel acm = new AutoCompleteComboBoxModel();
ArrayList<String> t = new ArrayList<String>();
t.add("[same state]");
Dfa d = getdFAMainWin().getDfaSim().g... | 1 |
private boolean cellIsFree(int x, int y){
if(field[x][y] == DEFAULT_CELL_VALUE){
return true;
} else {
return false;
}
} | 1 |
public Labyrinth(int height, int width) {
try {
caseArray = new Case[height][width];
for (int a = 0; a < height; a++) {
for (int b = 0; b < width; b++) {
caseArray[a][b] = new Case(a, b);
}
}
cells = height * wid... | 3 |
private static int checkTypeSignature(final String signature, int pos) {
// TypeSignature:
// Z | C | B | S | I | F | J | D | FieldTypeSignature
switch (getChar(signature, pos)) {
case 'Z':
case 'C':
case 'B':
case 'S':
case 'I':
case 'F':
case 'J':
case 'D':
return pos + 1;
default:
retu... | 8 |
public void loadFile(String path) throws IOException {
String thisLine; // variable to read each line.
BufferedReader myInput = null;
try {
FileInputStream fin = new FileInputStream(new File(path));
myInput = new BufferedReader(new InputStreamReader(fin));
// for each line until the end of the file
wh... | 7 |
@Override
protected void decode(ChannelHandlerContext chc, ByteBuf buf, List<Object> out) throws Exception {
byte id = buf.readByte();
byte[] data = new byte[buf.readableBytes()];
buf.readBytes(data);
Class<? extends Packet> clazz = Packet.packetIdMap.get(id);
if (cl... | 2 |
Subsets and Splits
SQL Console for giganticode/java-cmpx-v1
The query retrieves a limited number of text entries within a specific length range, providing basic filtering but minimal analytical insight.