private static String convert2PropName ( String argProp ) throws Exception { //System.out.println("argProp: " + argProp); if ( ! argProp . startsWith ( "--" ) ) { throw new Exception ( "argument: " + argProp + " does not start with --" ) ; } if ( argProp . indexOf ( "=" ) == - 1 ) { throw new Exception ( "argument: " + argProp + " does not contain an = sign" ) ; } // remove hyphens String argProperty = argProp . substring ( 2 ) ; if ( null == argProperty || "" . equals ( argProperty ) ) throw new Exception ( "argument: " + argProp + " not valid" ) ; // get the lhs of =, the property name String argPropName = argProperty . split ( "=" ) [ 0 ] ; if ( null == argPropName || "" . equals ( argPropName ) ) throw new Exception ( "argument: " + argProp + " not valid" ) ; // get the rhs of =, the property value int equalsAt = argProperty . indexOf ( ' ' ) ; String argPropValue = argProperty . substring ( equalsAt + 1 ) ; if ( null == argPropValue || "" . equals ( argPropValue ) ) throw new Exception ( "argument: " + argProp + " not valid" ) ; //System.out.println("argPropName: " + argPropName); // ensure this type of prop is one that we will handle //String[] dotSplit = argPropName.split("\\."); //String propType = dotSplit[0]; //if (Arrays.binarySearch(PREFS_ALLOWED_PROP_TYPES, propType) < 0) { //StringBuffer allowedProps = new StringBuffer(); //for (int i = 0; i < PREFS_ALLOWED_PROP_TYPES.length; i++) { //allowedProps.append(PREFS_ALLOWED_PROP_TYPES[i]); //allowedProps.append(" "); //} //throw new Exception("argument: " + argProp + " not allowed, " + //allowedProps.toString()); //} return argPropName ; }
also check if it is a valid type of property