- 1
- 2
- 3
- 4
- 5
} catch (CacheException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+70
} catch (CacheException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
Привет из Индии
+79
if (scannedLiteralType.compareTo("<!") == 0) {
if (textPosition + 5 < text.length) {
if (scannedByte == (byte)'[') {
if (text[textPosition] == (byte)'C') {
if (text[textPosition + 1] == (byte)'D') {
if (text[textPosition + 2] == (byte)'A') {
if (text[textPosition + 3] == (byte)'T') {
if (text[textPosition + 4] == (byte)'A') {
if (text[textPosition + 5] == (byte)'[') {
scanByte();
scanByte();
scanByte();
scanByte();
scanByte();
scanByte();
scanByte();
Element childNode = createNode("");
node.addChild(childNode);
scanBytes("]]>".getBytes(), false);
byte[] bytes = new byte[literalPosition - 1];
System.arraycopy(literal, 0, bytes, 0, literalPosition - 1);
try {
String string = new String(bytes, encoding);
childNode.setValue(string);
childNode.setIdentifier("<![SDATA[]]");
} catch (Exception exception) {
childNode.setValue(bytes);
childNode.setIdentifier("<![CDATA[]]");
}
scanByte();
scanByte();
scanByte();
scanToken();
continue;
}
}
}
}
}
}
}
}
проверка "CDATA"
+74
@Override
public boolean equals(Object obj) {
boolean answer = false;
if (obj instanceof Date) {
Date d = (Date)obj;
answer = (this.value.equals(d));
} else if (obj instanceof String) {
Date d = parse((String)obj);
answer = (this.value.equals(d));
} else if (obj instanceof Calendar) {
Calendar c = (Calendar)obj;
answer = (this.value.equals(c.getTime()));
} else if (obj instanceof AtomDate) {
Date d = ((AtomDate)obj).value;
answer = (this.value.equals(d));
}
return answer;
}
Симметрия отношения эквивалентности? Не, не слышал.
+90
public enum TimeUnit {
NANOSECONDS {
public long toNanos(long d) { return d; }
public long toMicros(long d) { return d/(C1/C0); }
public long toMillis(long d) { return d/(C2/C0); }
public long toSeconds(long d) { return d/(C3/C0); }
public long toMinutes(long d) { return d/(C4/C0); }
public long toHours(long d) { return d/(C5/C0); }
public long toDays(long d) { return d/(C6/C0); }
public long convert(long d, TimeUnit u) { return u.toNanos(d); }
int excessNanos(long d, long m) { return (int)(d - (m*C2)); }
}
....
public long convert(long sourceDuration, TimeUnit sourceUnit) {
throw new AbstractMethodError();
}
public long toNanos(long duration) {
throw new AbstractMethodError();
}
public long toMicros(long duration) {
throw new AbstractMethodError();
}
public long toMillis(long duration) {
throw new AbstractMethodError();
}
public long toSeconds(long duration) {
throw new AbstractMethodError();
}
public long toMinutes(long duration) {
throw new AbstractMethodError();
}
public long toHours(long duration) {
throw new AbstractMethodError();
}
public long toDays(long duration) {
throw new AbstractMethodError();
}
abstract int excessNanos(long d, long m);
}
Но зачем?
+75
public static class FuckMeGentlyWithAChainsaw {
/* This wrapper class exists to work around the possibly most
* stupid Java bug ever (and that's saying a lot): That
* URL.equals and URL.hashCode do DNS lookups and
* block. Which, of course, not only sucks performance-wise
* but also breaks actual correct URL equality. */
public final URL url;
public FuckMeGentlyWithAChainsaw(URL url) {
this.url = url;
}
}
Код из клиента одной онлайн игрушки, процитирован дословно.
+62
public synchronized void changePassword(String password, int id){
try {
Connection conn = Db.getInstance().createConnection();
Statement stmt = conn.createStatement();
String sql = "UPDATE "+tableName+"SET `password` ='"+password+"' WHERE `userId` ="+id+"";
stmt.executeUpdate(sql);
}
catch(Exception ex){
Logger.writeToFile("Exception occured " + ex.toString());
}
}
Типичная лаба
+81
if (uf.getPath().contains("d:/test.java/uploads/")) {
uf.setPath(uf.getPath().replace("d:/test.java/uploads/", this.uploadPath));
}
+79
String url = m_launchUrl.replaceAll(" ", "%20");
Percent-encode по-Адобовски.
http://svn.apache.org/repos/asf/incubator/flex/trunk/modules/debugger/src/java/flash/tools/debugger/concrete/PlayerSession.java
+100
synchronized(new Object()){
...
}
http://stackoverflow.com/questions/9840959/how-to-judge-which-object-to-be-synchronized-in-java-thread
+77
@Override
public String toString(){
return this.toString();
}