自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
TfInternalOptionsFetcher
public
class
TfInternalOptionsFetcher
extends Object
java.lang.Object
|
↳ |
com.android.tradefed.util.TfInternalOptionsFetcher
|
一个实用程序类,允许类从 res 文件中静态加载变量值。
资源文件应采用键值对格式,其中键与需要检索的变量相关联。单个资源文件可以包含多行,其中每行都与一个变量相关联。
如需指定任何基元类型,应在一行中使用单个键值对。例如:
- my-integer-key=5
- my-string-key=myStringValue
如需指定任何集合,可以使用多个值,并以英文逗号(,) 分隔。例如:
- my-string-list-key=stringOne,stringTwo,stringThree
- my-int-list-key=1,2,3,4,5
如需指定映射,可以使用多个 mapKey\=mapValue 对,以英文逗号(,) 分隔。例如:
- my-map-key=mapKey1\=mapVal1,mapKey2\=mapVal2
摘要
公共构造函数
TfInternalOptionsFetcher
public TfInternalOptionsFetcher ()
公共方法
fetchOption
public static void fetchOption (Class<?> classObj)
从指定的资源文件中提取给定 Class
的所有声明字段的值。如果未设置资源文件,系统将使用默认资源文件。
参数 |
classObj |
Class :应填充字段的类 Object 。 |
setResourcePath
public static void setResourcePath (String path)
设置要从中检索值的资源文件的路径。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# TfInternalOptionsFetcher\n========================\n\n\n`\npublic\n\n\nclass\nTfInternalOptionsFetcher\n`\n\n\n`\n\nextends Object\n\n\n`\n\n`\n\n\n`\n\n|---|----------------------------------------------------|\n| java.lang.Object ||\n| ↳ | com.android.tradefed.util.TfInternalOptionsFetcher |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nA utility class that allows classes to load a variables value statically from a res file.\n\nThe resource file should be in a key=value format, where the key is associated with the\nvariable that needs to be retrieved. A single resource file can contain multiple lines, where\neach line is associated with one variable.\n\nTo specify any primitive types, a single key=value pair should be used in a line. e.g.:\n\n1. my-integer-key=5\n2. my-string-key=myStringValue\n\nTo specify any collections, multiple values can be used, separated by a comma(,). e.g.:\n\n1. my-string-list-key=stringOne,stringTwo,stringThree\n2. my-int-list-key=1,2,3,4,5\n\nTo specify a map, multiple mapKey\\\\=mapValue pair can be used, separated by a comma(,). e.g.:\n\n1. my-map-key=mapKey1\\\\=mapVal1,mapKey2\\\\=mapVal2\n\n\u003cbr /\u003e\n\nSummary\n-------\n\n| ### Public constructors ||\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| ` `[TfInternalOptionsFetcher](../../../../../../reference/tradefed/com/android/tradefed/util/TfInternalOptionsFetcher.html#TfInternalOptionsFetcher())`() ` |\n\n| ### Public methods ||\n|----------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| ` static void` | ` `[fetchOption](../../../../../../reference/tradefed/com/android/tradefed/util/TfInternalOptionsFetcher.html#fetchOption(java.lang.Class\u003c?\u003e))`(Class\u003c?\u003e classObj) ` Fetches the values for all declared fields of the given [Class](../../../../../../reference/tradefed/java/lang/Class.html) from the specified resource file. |\n| ` static void` | ` `[setResourcePath](../../../../../../reference/tradefed/com/android/tradefed/util/TfInternalOptionsFetcher.html#setResourcePath(java.lang.String))`(String path) ` Set the path of the resource file where the value will be retrieved from. |\n\nPublic constructors\n-------------------\n\n### TfInternalOptionsFetcher\n\n```\npublic TfInternalOptionsFetcher ()\n```\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nPublic methods\n--------------\n\n### fetchOption\n\n```\npublic static void fetchOption (Class\u003c?\u003e classObj)\n```\n\nFetches the values for all declared fields of the given [Class](../../../../../../reference/tradefed/java/lang/Class.html) from the specified\nresource file. If a resource file is not set, a default resource file will be used.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|------------|----------------------------------------------------------------------------------------------------------------------------------|\n| `classObj` | `Class`: the class [Object](../../../../../../reference/tradefed/java/lang/Object.html) whose fields should be populated. \u003cbr /\u003e |\n\n### setResourcePath\n\n```\npublic static void setResourcePath (String path)\n```\n\nSet the path of the resource file where the value will be retrieved from.\n\n\u003cbr /\u003e\n\n| Parameters ||\n|--------|-----------------|\n| `path` | `String` \u003cbr /\u003e |"]]