<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: static code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sat, 17 May 2008 20:00:44 GMT</pubDate>
    <description>DZone Snippets: static code</description>
    <item>
      <title>Obtaining the value of a public static field by reflexion </title>
      <link>http://snippets.dzone.com/posts/show/4501</link>
      <description>// Obtaining the value of a static public constant of a class, here Boolean for example&lt;br /&gt;&lt;code&gt;&lt;br /&gt;        Object returnedObj = null;&lt;br /&gt;        try {&lt;br /&gt;            Class clazz = Class.forName("java.lang.Boolean");&lt;br /&gt;            returnedObj = clazz.getField("TRUE").get(clazz);&lt;br /&gt;            assert java.lang.Boolean.TRUE == returnedObj : "wrong returned object";&lt;br /&gt;        } catch (ClassNotFoundException e) {&lt;br /&gt;            e.printStackTrace();&lt;br /&gt;        } catch (SecurityException e) {&lt;br /&gt;            e.printStackTrace();&lt;br /&gt;        } catch (NoSuchFieldException e) {&lt;br /&gt;            e.printStackTrace();&lt;br /&gt;        } catch (IllegalArgumentException e) {&lt;br /&gt;            e.printStackTrace();&lt;br /&gt;        } catch (IllegalAccessException e) {&lt;br /&gt;            e.printStackTrace();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        return returnedObj;&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 06 Sep 2007 14:59:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4501</guid>
      <author>Archanciel (Jean-Pierre Schnyder)</author>
    </item>
    <item>
      <title>classmethod and staticmethod</title>
      <link>http://snippets.dzone.com/posts/show/1679</link>
      <description>&lt;code&gt;&lt;br /&gt;class K(object):&lt;br /&gt;&lt;br /&gt;  # normal method (instance method)&lt;br /&gt;  def method1(self):&lt;br /&gt;    print 'obj.method1() becomes method1(obj)'&lt;br /&gt;&lt;br /&gt;  # class method&lt;br /&gt;  def method2(cls):&lt;br /&gt;    print 'K.method2() becomes method2(K)'&lt;br /&gt;  method2 = classmethod(method2)&lt;br /&gt;&lt;br /&gt;  # static method&lt;br /&gt;  def method3():&lt;br /&gt;    print 'K.method3() become just method3()'&lt;br /&gt;  method3 = staticmethod(method3)&lt;br /&gt;&lt;br /&gt;obj = K()&lt;br /&gt;obj.method1()&lt;br /&gt;K.method2()&lt;br /&gt;K.method3()&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Fri, 10 Mar 2006 14:51:25 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1679</guid>
      <author>korakot (Korakot Chaovavanich)</author>
    </item>
  </channel>
</rss>
