public static java.util.List | parseHardwareDefinitions(java.io.File file, com.android.sdklib.ISdkLog log)Parses the hardware definition file.
try {
FileInputStream fis = new FileInputStream(file);
BufferedReader reader = new BufferedReader(new InputStreamReader(fis));
List<HardwareProperty> map = new ArrayList<HardwareProperty>();
String line = null;
HardwareProperty prop = null;
while ((line = reader.readLine()) != null) {
if (line.length() > 0 && line.charAt(0) != '#") {
Matcher m = PATTERN_PROP.matcher(line);
if (m.matches()) {
String valueName = m.group(1);
String value = m.group(2);
if (HW_PROP_NAME.equals(valueName)) {
prop = new HardwareProperty();
prop.mName = value;
map.add(prop);
}
if (prop == null) {
log.warning("Error parsing '%1$s': missing '%2$s'",
file.getAbsolutePath(), HW_PROP_NAME);
return null;
}
if (HW_PROP_TYPE.equals(valueName)) {
prop.mType = ValueType.getEnum(value);
} else if (HW_PROP_DEFAULT.equals(valueName)) {
prop.mDefault = value;
} else if (HW_PROP_ABSTRACT.equals(valueName)) {
prop.mAbstract = value;
} else if (HW_PROP_DESC.equals(valueName)) {
prop.mDescription = value;
}
} else {
log.warning("Error parsing '%1$s': \"%2$s\" is not a valid syntax",
file.getAbsolutePath(), line);
return null;
}
}
}
return map;
} catch (FileNotFoundException e) {
// this should not happen since we usually test the file existence before
// calling the method.
// Return null below.
} catch (IOException e) {
if (log != null) {
log.warning("Error parsing '%1$s': %2$s.", file.getAbsolutePath(),
e.getMessage());
}
}
return null;
|