-
+73.6
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
package psorter;
import java.util.Vector;
public class CArray extends Vector {
String type="";
/**
* constructor of /array/
* @param i set capacity increment
*/
public CArray(int i) {
this.capacityIncrement=i;
}
/**
* add object to end of vector with check of type
* if type same as @ first added - add this object
* safer than add
* @param o object to add
*/
public void append(Object o) {
if ( this.type.equals("") )
this.type=o.getClass().toString();
if ( o.getClass().toString().equals(this.type) ){
this.add(o);
} else {
if ( this.type.contains("Float") && o.getClass().toString().contains("Integer") )
this.add( Float.valueOf(o.toString()) );
if ( this.type.contains("Double") && o.getClass().toString().contains("Integer") )
this.add( Double.valueOf(o.toString()) );
if ( this.type.contains("Double") && o.getClass().toString().contains("Float") )
this.add( Double.valueOf(o.toString()) );
if ( this.type.contains("String") && o.getClass().toString().contains("Char") )
this.add( o.toString() );
}
}
public byte compare(int i, int j) throws Exception {
if (type.contains("Integer")) {
if ((Integer) (this.get(i)) > (Integer) (this.get(j)))
return 1;
if ((Integer) (this.get(i)) < (Integer) (this.get(j)))
return -1;
return 0;
}
if (type.contains("Float")) {
if ((Float) (this.get(i)) > (Float) (this.get(j)))
return 1;
if ((Float) (this.get(i)) < (Float) (this.get(j)))
return -1;
return 0;
}
if (type.contains("Double")) {
if ((Double) (this.get(i)) > (Double) (this.get(j)))
return 1;
if ((Double) (this.get(i)) < (Double) (this.get(j)))
return -1;
return 0;
}
if (type.contains("Char")) {
if ((Character) (this.get(i)) > (Character) (this.get(j)))
return 1;
if ((Character) (this.get(i)) < (Character) (this.get(j)))
return -1;
return 0;
}
if (type.contains("String")) {
if ( this.get(i).toString().compareTo(this.get(j).toString())>0 )
return 1;
if ( this.get(i).toString().compareTo(this.get(j).toString())<0 )
return -1;
return 0;
}
return 0;
}
}
сел писать 3 лабы естественно в последнюю ночь. начал в 11. эта была около 3х. самому потом стыдно было нести такое
ilardm,
17 Апреля 2010
-
+74.2
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
package efi.base.business.metadata;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class MetaModel {
private String name = null;
private List attributeNames = new ArrayList();
private List attributeValues = new ArrayList();
public MetaModel(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void addAttribute(Attribute attribute) {
attributeNames.add(attribute.getName());
attributeValues.add(attribute);
}
public Attribute getAttribute(String attrubuteName) {
return (Attribute) attributeValues.get(attributeNames.indexOf(attrubuteName));
}
public Iterator attributesIterator() {
return attributeNames.iterator();
}
}
Человек, писавший этот говнокласс, видимо и не подозревал, что в JDK кроме листов есть еще и Map-ы :-)
Andronix,
14 Апреля 2010
-
+64.8
- 1
- 2
- 3
- 4
long timer = -System.currentTimeMillis();
method.invoke(...);
timer += System.currentTimeMillis();
log.info("Executed: " + timer + " ms.");
Obychno ja delaju dve peremennyje start i end:
long start = System.currentTimeMillis();
method.invoke(...);
long end = System.currentTimeMillis();
log.info("Executed: " + (end-start) + " ms.");
Inogda ewe ljudi pishut s odnoj peremennoj, no tut vpolne ponjatno, chto v nej hranitsja:
long t = System.currentTimeMillis();
method.invoke(...);
t = System.currentTimeMillis() - t;
A vot zafigachit' v peremennuju "timer" OTRITSATEL'NOJE znachenije - eto da...
asolntsev,
13 Апреля 2010
-
+72.4
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
interface Editor extends Window {
/** Get edited entity */
Entity getItem();
/**
* Set parent datasource to commit into this datasource instead of database.
* This method must be followed by {@link #setItem(com.contora.package.core.entity.Entity)}
*/
void setParentDs(Datasource parentDs);
/** Set edited entity. Invoked by the framework on opening the window. */
void setItem(Entity item);
/** Check validity by invoking validators on all components which support them */
boolean isValid();
/** Check validity by invoking validators on all components which support them */
void validate() throws ValidationException;
/** Validate and commit changes */
boolean commit();
/** Commit changes with optional validating */
boolean commit(boolean validate);
/**
* Validate, commit and close if commit was successful.
* Passes {@link #COMMIT_ACTION_ID} to associated {@link CloseListener}s
*/
void commitAndClose();
}
public class PickupRegionLookuper extends AbstractLookup implements Editor{
public PickupRegionLookuper(IFrame frame) {
super(frame);
}
@Override
protected void init(Map<String, Object> params) {
//Здесь была какая то логика
}
@Override
public Entity getItem() {
return null;
}
@Override
public void setParentDs(Datasource parentDs) {
}
@Override
public void setItem(Entity item) {
}
@Override
public boolean isValid() {
return false;
}
@Override
public void validate() throws ValidationException {
}
@Override
public boolean commit() {
return false;
}
@Override
public boolean commit(boolean validate) {
return false;
}
@Override
public void commitAndClose() {
}
}
Встретилось в одном java-файле. Класс реализует интерфейс, определенный в том же файле, причем интерфейс package-private (!). При этом ни одного метода оттуда реально не используется. К тому же этот интерфейс человек перенес из другого класса, где тот был как раз public.
tinhol,
06 Апреля 2010
-
+69.2
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
List<Measure> meaList = q.getResultList();
try
{
if (meaList.size() == 0)
{
throw new Exception("Measure not found: "+_wsPrice.getMeasureIso());
}
else
{
p.setMeasure(meaList.get(0));
}
}
finally
{
meaList.clear();
}
А вот ещё порция паранойи от моего коллеги
konsoletyper,
06 Апреля 2010
-
+77.6
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
public void run()
{
try
{
startExport();
}
catch (Throwable _t)
{
sendEvent(""+_t.getMessage(), true);
logger.log(Level.SEVERE, charset, _t);
}
finally
{
System.gc();
}
}
А ещё этот человек дёргает в одном сервисе gc каждые 4 секунды. Любые попытки ударить по рукам нарываются на отлуп: "так работает же!". Это не студент! Это реальный production код!
konsoletyper,
06 Апреля 2010
-
+67.4
- 1
- 2
Apache POI
The apache project has a library which called POI that can read and write the HSSF (Horrible Spread Sheet Format)
Не говнокод, но официальное название формата доставляет :)
zlob.jc,
02 Апреля 2010
-
+69
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
if (isRenderVerifyClaimTab()) {
addContrToInit("com.cs.creditecspert.webjsf.controllers.ddeControllers.VerifyClaimController");
}
if (isRenderVerifyAvtoTab()) {
addContrToInit("com.cs.creditecspert.webjsf.controllers.ddeControllers.VerifyAvtoController");
}
if (isRenderUntipicalClaimTab()) {
addContrToInit("com.cs.creditecspert.webjsf.controllers.ddeControllers.UntipicalClaimController");
}
if (isRenderTypeClaimTab()) {
addContrToInit("com.cs.creditecspert.webjsf.controllers.ddeControllers.TypeClaimController");
}
Профтыкал что можно было делать так:
if (isRenderCheckClaimTab()) {
addContrToInit(CheckClaimController.clas s.getName());
}
:)
Lockdog,
01 Апреля 2010
-
+74.4
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
private String getNullString(int kol){
String nullstr="";
for(int i=0;i<kol;i++){
nullstr+="0";
}
return nullstr;
}
public String getNumber(int idd){
String regid="";
String idds=(idd+"");
if(idds.length()<getNumberLenth()){
regid+=getNullString(getNumberLenth()-idds.length());
regid+=idds;
}
String regnum="";
regnum+=getNumberPrefix()+regid;
if(getNumberPeriod()!=NUM_PERIOD_NOPERIOD){
GregorianCalendar c=new GregorianCalendar();
switch(getNumberPeriod()){
case NUM_PERIOD_MONTH:
int m=c.get(Calendar.MONTH)+1;
regnum+="-"+m;
regnum+=".";
regnum+=c.get(Calendar.YEAR);
break;
case NUM_PERIOD_YEAR:
regnum+="-"+c.get(Calendar.YEAR);
}
}
return regnum;
}
Ну незнал я про String.format (((..
maxt,
01 Апреля 2010
-
+74
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
lstCmsObject = OpenCms.getOrgUnitManager().getGroups(obj, "/", true);
for (int i = 0; i < lstCmsObject.size(); i++)
{
lstUnits.add(new Units(lstCmsObject.get(i).getDisplayName(obj, Locale.US).replaceAll("Users from ","").replaceAll("[a-zA-Z]*","").replaceAll("[(/)]+",""),lstCmsObject.get(i).getOuFqn()));
}
for (int i = 0; i < lstCmsObject.size(); i++) {
for (int j = 0; j < lstCmsObject.size(); j++) {
if (lstUnits.get(i).GetName().compareTo(lstUnits.get(j).GetName())<0) {
Collections.swap(lstUnits, i, j);
}
}
}
des-1008d,
30 Марта 2010