test_class.file: tigase-server 7.1.0/src/test/java/tigase/util/DataTypesTest.java
test_class.identifier: DataTypesTest
test_case.body: @Test
  	public void testParseNum() {
  
  		assertEquals( new Long( 262144L ), Long.valueOf( Integer.class.cast( DataTypes.parseNum( "256k", Integer.class, 1 ) ) ) );
  		assertEquals( new Long( 262144L ), Long.class.cast( DataTypes.parseNum( "256k", Long.class, 1L ) ) );
  		assertEquals( new Double( 670720.0D ), Double.class.cast( DataTypes.parseNum( "655k", Double.class, 1D ) ) );
  		assertEquals( new Double( 262144F ), Double.valueOf( Float.class.cast( DataTypes.parseNum( "256k", Float.class, 1F ) ) ) );
  		assertEquals( new Long( 25 ), Long.valueOf( (long) DataTypes.parseNum( "25", Short.class, Short.valueOf( "1" ) ) ) );
  		assertEquals( new Long( 25 ), Long.valueOf( Byte.class.cast( DataTypes.parseNum( "25", Byte.class, Byte.valueOf( "1" ) ) ) ) );
  	}
test_case.class_method_signature: DataTypesTest.testParseNum()
test_case.full_signature: @Test public void testParseNum()
test_case.identifier: testParseNum
test_case.invocations: assertEquals valueOf cast parseNum assertEquals cast parseNum assertEquals cast parseNum assertEquals valueOf cast parseNum assertEquals valueOf parseNum valueOf assertEquals valueOf cast parseNum valueOf
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testParseNum()
focal_class.declarator: typesMap = new LinkedHashMap<String,
  																													Character>()
focal_class.modifier: public static final
focal_class.original_string: public static final Map<String, Character> typesMap = new LinkedHashMap<String,
  																													Character>();
focal_class.type: Map<String, Character>
focal_class.var_name: typesMap
focal_class.declarator: log = Logger.getLogger(DataTypes.class.getName())
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = Logger.getLogger(DataTypes.class.getName());
focal_class.type: Logger
focal_class.var_name: log
focal_class.file: tigase-server 7.1.0/src/main/java/tigase/util/DataTypes.java
focal_class.identifier: DataTypes
focal_class.class_method_signature: DataTypes.parseNum(String num, Class<T> cls, T def)
focal_class.full_signature: public static T parseNum(String num, Class<T> cls, T def)
focal_class.identifier: parseNum
focal_class.modifiers: public static
focal_class.parameters: (String num, Class<T> cls, T def)
focal_class.return: T
focal_class.signature: T parseNum(String num, Class<T> cls, T def)
focal_class.class_method_signature: DataTypes.parseSizeInt(String size, int def)
focal_class.full_signature: public static int parseSizeInt(String size, int def)
focal_class.identifier: parseSizeInt
focal_class.modifiers: public static
focal_class.parameters: (String size, int def)
focal_class.return: int
focal_class.signature: int parseSizeInt(String size, int def)
focal_class.class_method_signature: DataTypes.parseBool(final String val)
focal_class.full_signature: public static boolean parseBool(final String val)
focal_class.identifier: parseBool
focal_class.modifiers: public static
focal_class.parameters: (final String val)
focal_class.return: boolean
focal_class.signature: boolean parseBool(final String val)
focal_class.class_method_signature: DataTypes.decodeValueType(char typeId, String value)
focal_class.full_signature: public static Object decodeValueType(char typeId, String value)
focal_class.identifier: decodeValueType
focal_class.modifiers: public static
focal_class.parameters: (char typeId, String value)
focal_class.return: Object
focal_class.signature: Object decodeValueType(char typeId, String value)
focal_class.class_method_signature: DataTypes.valueToString(final Object value)
focal_class.full_signature: public static String valueToString(final Object value)
focal_class.identifier: valueToString
focal_class.modifiers: public static
focal_class.parameters: (final Object value)
focal_class.return: String
focal_class.signature: String valueToString(final Object value)
focal_class.class_method_signature: DataTypes.decodeTypeIdFromName(String name)
focal_class.full_signature: public static char decodeTypeIdFromName(String name)
focal_class.identifier: decodeTypeIdFromName
focal_class.modifiers: public static
focal_class.parameters: (String name)
focal_class.return: char
focal_class.signature: char decodeTypeIdFromName(String name)
focal_class.class_method_signature: DataTypes.stripNameFromTypeId(String name)
focal_class.full_signature: public static String stripNameFromTypeId(String name)
focal_class.identifier: stripNameFromTypeId
focal_class.modifiers: public static
focal_class.parameters: (String name)
focal_class.return: String
focal_class.signature: String stripNameFromTypeId(String name)
focal_class.class_method_signature: DataTypes.encodeTypeIdInName(String name, Object value)
focal_class.full_signature: public static String encodeTypeIdInName(String name, Object value)
focal_class.identifier: encodeTypeIdInName
focal_class.modifiers: public static
focal_class.parameters: (String name, Object value)
focal_class.return: String
focal_class.signature: String encodeTypeIdInName(String name, Object value)
focal_class.class_method_signature: DataTypes.getTypeId(Object instance)
focal_class.full_signature: public static char getTypeId(Object instance)
focal_class.identifier: getTypeId
focal_class.modifiers: public static
focal_class.parameters: (Object instance)
focal_class.return: char
focal_class.signature: char getTypeId(Object instance)
focal_class.class_method_signature: DataTypes.getProperty(String key, Boolean def)
focal_class.full_signature: public static boolean getProperty(String key, Boolean def)
focal_class.identifier: getProperty
focal_class.modifiers: public static
focal_class.parameters: (String key, Boolean def)
focal_class.return: boolean
focal_class.signature: boolean getProperty(String key, Boolean def)
focal_class.class_method_signature: DataTypes.main( String[] args )
focal_class.full_signature: public static void main( String[] args )
focal_class.identifier: main
focal_class.modifiers: public static
focal_class.parameters: ( String[] args )
focal_class.return: void
focal_class.signature: void main( String[] args )
focal_method.body: public static <T extends Number> T parseNum(String num, Class<T> cls, T def) {
  		if (num == null) {
  			return def;
  		}
  
  		T result        = def;
  		String toParse  = num;
  		Long multiplier = 1L;
  
  		try {
  			switch (num.charAt(num.length() - 1)) {
  			case 'k' :
  			case 'K' :
  				multiplier = 1024L;
  				toParse    = num.substring(0, num.length() - 1);
  
  				break;
  
  			case 'm' :
  			case 'M' :
  				multiplier = 1024L * 1024L;
  				toParse    = num.substring(0, num.length() - 1);
  
  				break;
  
  			case 'g' :
  			case 'G' :
  				multiplier = 1024L * 1024L * 1024L;
  				toParse    = num.substring(0, num.length() - 1);
  
  				break;
  			}
  
  			if(cls.equals(Integer.class)) {
  				result = cls.cast(Integer.valueOf(toParse) * multiplier.intValue());
  			} else if(cls.equals(Long.class)) {
  				result = cls.cast(Long.valueOf(toParse) * multiplier);
  			} else if(cls.equals(Double.class)) {
  				result = cls.cast(Double.valueOf(toParse) * multiplier.doubleValue());
  			} else if(cls.equals(Float.class)) {
  				result = cls.cast(Float.valueOf(toParse) * multiplier.floatValue());
  			} else if(cls.equals(Byte.class)) {
  				Integer res = Byte.valueOf(toParse) * multiplier.byteValue();
  				result = cls.cast(res.byteValue());
  			} else if(cls.equals(Short.class)) {
  				Integer res = Short.valueOf(toParse) * multiplier.shortValue();
  				result = cls.cast(res.shortValue());
  			}
  		} catch (Exception e) {
  			log.log( Level.WARNING, "Error parsing value: {0} as {1}, using default: {2}", new Object[] {num,cls,def});
  			return def;
  		}
  
  		return result;
  	}
focal_method.class_method_signature: DataTypes.parseNum(String num, Class<T> cls, T def)
focal_method.full_signature: public static T parseNum(String num, Class<T> cls, T def)
focal_method.identifier: parseNum
focal_method.invocations: charAt length substring length substring length substring length equals cast valueOf intValue equals cast valueOf equals cast valueOf doubleValue equals cast valueOf floatValue equals valueOf byteValue cast byteValue equals valueOf shortValue cast shortValue log
focal_method.modifiers: public static
focal_method.parameters: (String num, Class<T> cls, T def)
focal_method.return: T
focal_method.signature: T parseNum(String num, Class<T> cls, T def)