Recent Notes

Displaying keyword search results 101 - 110
Created by alfa on May 27, 2011 11:19:29    Last update: May 31, 2011 07:56:26
This is a utility to convert a string value to one of the primitive type values. It is useful in Java reflection code where the value comes in as a string (e.g., from XML parsing), and the type of the value cannot be decided until runtime. import java.util.*; import java.lang.reflect.*;... Note: This method can be extended to convert string to more complex types by writing a converter for the destination type. For example, to convert string to date: public class DateConverter { public static ... Usage: Date d = (Date) ConvertUtil.convert("10/12/2010", ...
Created by alfa on May 26, 2011 14:23:33    Last update: May 26, 2011 14:25:42
For Java arrays, the class name is [ followed by an encoded name of the element class. The number of [ characters represents the number of dimensions of the array. The class name encoding is following: Element Type Encoding boolean Z byte B char C class or interface L classname; double D float F int I long J short S Example: public class ClassNameEncoding { public sta...
Created by alfa on May 24, 2011 16:08:34    Last update: May 24, 2011 16:09:02
There are two ways to get the Class object for primitive types: Type name followed by .class : Class intClass = int.class TYPE field for the corresponding wrapper class: Class doubleClass = Double.TYPE; Class.forName() does not work for primitive types. But it works for primitive arrays: Class c1 = int[].class; Class c2 = Class.forNam...
Created by alfa on May 24, 2011 15:59:41    Last update: May 24, 2011 15:59:41
Java reflection with Apache beanutils example. import org.apache.commons.beanutils.MethodUtils; ...
Created by James on May 19, 2011 16:02:40    Last update: May 19, 2011 16:05:05
Finally, MathJax makes showing math equations in the browser a reality! Here are some simple demos. A simple example: <!doctype html> <html> <head> <title>Math... Add HTML styling for Firefox: <!doctype html> <html> <head> <title>Math...
Created by James on March 27, 2009 03:20:58    Last update: May 08, 2011 12:32:31
Use show create table <tablename> : mysql> show create table my_test_table; +------... Select from information_schema.table_constraints and information_schema.key_column_usage mysql> select * from information_schema.table_cons...
Created by freyo on May 06, 2011 16:07:33    Last update: May 06, 2011 16:08:36
Private key: -----BEGIN PRIVATE KEY----- MIIEvAIBADANBgkqhki... Certificate: -----BEGIN CERTIFICATE----- MIIEqDCCA5CgAwIBAgI... Import the key pair to the debug keystore: $ cat platform.pem platform.x509.pem >platform-key...
Created by Dr. Xi on May 03, 2011 14:27:15    Last update: May 03, 2011 14:28:06
The XML schema for a contact might look like this: <?xml version="1.0" encoding="UTF-8"?> <schema ... With XML digital signatures , a Signature element is inserted inside the contact element after the contact file is signed. Like this: <?xml version="1.0" encoding="UTF-8" standalone="n... which no longer validates with the original schema. The schema should be updated to (with the addition of digital signature namespace, schema import and Signature ref ): <?xml version="1.0" encoding="UTF-8"?> <schema ...
Created by jinx on May 03, 2011 12:11:35    Last update: May 03, 2011 12:12:27
The PHP function is_resource returns TRUE if a variable is a resource. This may come in handy when a function you are calling returns mixed type. For example mysql_query returns TRUE or FALSE for INSERT , UPDATE , DELETE etc., but returns resource or FALSE for SELECT , SHOW , or DESCRIBE . <?php $rows = array(); if ($res = mysql_quer...
Created by jinx on May 03, 2011 11:43:26    Last update: May 03, 2011 11:43:26
The PHP function strval returns the string value of a variable. It does the same thing as casting a variable to string, or automatic conversion where string is expected. Conversion rules: Type String Value Boolean TRUE '1' Boolean FALSE '' (empty string) integer of float string representing the number Array The string 'Array' Object Result of __toString() if defined, error otherwise Resource 'Resource id #n' , where n is a number assigned to the resource. NULL '' (empty string) Example: <?php set_error_handler(function($errno, $errst... Results: bool(true) --------------------- strval: '1'...
Previous  6 7 8 9 10 11 12 13 14 15 Next