Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release
thay vì aosp-main
để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
TfInternalOptionsFetcher
public
class
TfInternalOptionsFetcher
extends Object
java.lang.Object
|
↳ |
com.android.tradefed.util.TfInternalOptionsFetcher
|
Một lớp tiện ích cho phép các lớp tải giá trị biến một cách tĩnh từ tệp tài nguyên.
Tệp tài nguyên phải ở định dạng khoá=giá trị, trong đó khoá được liên kết với biến cần truy xuất. Một tệp tài nguyên có thể chứa nhiều dòng, trong đó mỗi dòng được liên kết với một biến.
Để chỉ định bất kỳ loại dữ liệu gốc nào, bạn nên sử dụng một cặp khoá=giá trị duy nhất trong một dòng. Ví dụ:
- my-integer-key=5
- my-string-key=myStringValue
Để chỉ định bất kỳ tập hợp nào, bạn có thể sử dụng nhiều giá trị, phân tách bằng dấu phẩy(,). Ví dụ:
- my-string-list-key=stringOne,stringTwo,stringThree
- my-int-list-key=1,2,3,4,5
Để chỉ định một bản đồ, bạn có thể sử dụng nhiều cặp mapKey\=mapValue, phân tách bằng dấu phẩy(,). Ví dụ:
- my-map-key=mapKey1\=mapVal1,mapKey2\=mapVal2
Tóm tắt
Phương thức công khai |
static
void
|
fetchOption(Class<?> classObj)
Tìm nạp các giá trị cho tất cả các trường đã khai báo của Class nhất định từ tệp tài nguyên được chỉ định.
|
static
void
|
setResourcePath(String path)
Đặt đường dẫn của tệp tài nguyên nơi giá trị sẽ được truy xuất.
|
Hàm khởi tạo công khai
TfInternalOptionsFetcher
public TfInternalOptionsFetcher ()
Phương thức công khai
fetchOption
public static void fetchOption (Class<?> classObj)
Tìm nạp các giá trị cho tất cả các trường đã khai báo của Class
nhất định từ tệp tài nguyên được chỉ định. Nếu bạn không đặt tệp tài nguyên, hệ thống sẽ sử dụng tệp tài nguyên mặc định.
Tham số |
classObj |
Class : lớp Object có các trường cần được điền sẵn. |
setResourcePath
public static void setResourcePath (String path)
Đặt đường dẫn của tệp tài nguyên nơi giá trị sẽ được truy xuất.
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-07-27 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-07-27 UTC."],[],[],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 |"]]