ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
TfInternalOptionsFetcher
public
class
TfInternalOptionsFetcher
extends Object
java.lang.Object
|
↳ |
com.android.tradefed.util.TfInternalOptionsFetcher
|
คลาสยูทิลิตีที่ช่วยให้คลาสโหลดค่าตัวแปรแบบคงที่จากไฟล์ res ได้
ไฟล์ทรัพยากรควรอยู่ในรูปแบบคีย์=ค่า โดยที่คีย์จะเชื่อมโยงกับตัวแปรที่ต้องดึงข้อมูล ไฟล์ทรัพยากรไฟล์เดียวอาจมีหลายบรรทัด โดยแต่ละบรรทัดจะเชื่อมโยงกับตัวแปร 1 รายการ
หากต้องการระบุประเภทพื้นฐานใดก็ตาม คุณควรใช้คู่คีย์=ค่ารายการเดียวในบรรทัด เช่น
- 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
สรุป
เมธอดสาธารณะ |
static
void
|
fetchOption(Class<?> classObj)
ดึงค่าสำหรับช่องที่ประกาศทั้งหมดของ Class ที่ระบุจากไฟล์ทรัพยากรที่ระบุ
|
static
void
|
setResourcePath(String path)
ตั้งค่าเส้นทางของไฟล์ทรัพยากรที่จะดึงข้อมูลค่า
|
ตัวสร้างแบบสาธารณะ
TfInternalOptionsFetcher
public TfInternalOptionsFetcher ()
เมธอดสาธารณะ
fetchOption
public static void fetchOption (Class<?> classObj)
ดึงค่าสำหรับช่องที่ประกาศทั้งหมดของ Class
ที่ระบุจากไฟล์ทรัพยากรที่ระบุ หากไม่ได้ตั้งค่าไฟล์ทรัพยากร ระบบจะใช้ไฟล์ทรัพยากรเริ่มต้น
พารามิเตอร์ |
classObj |
Class : คลาส Object ที่ควรป้อนข้อมูลในช่อง |
setResourcePath
public static void setResourcePath (String path)
ตั้งค่าเส้นทางของไฟล์ทรัพยากรที่จะดึงค่า
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","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"]],["อัปเดตล่าสุด 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 |"]]