普贤教程 › 包参考
properties 包
Java .properties 解析
| 项 | 值 |
|---|---|
| 包名 | properties |
| 版本 | 0.2.0 |
| 可用版本 | 0.1.0 / 0.2.0 |
| 入口 | properties.px |
| 分类 | 数据格式与编解码 |
| 文件数 / 行数 | 1 / 186 |
安装与引入
bash
pxpkg init # 首次 pxpkg add properties@0.2.0 pxpkg install
px
import properties所属分类教程:数据格式与编解码
公开接口
| 函数 | 参数 |
|---|---|
pr_parse | s |
pr_get | cfg, k |
pr_has | cfg, k |
pr_keys | cfg |
其余 11 个 def(内部与辅助,可直接调用但不属稳定接口)
| 函数 | 参数 |
|---|---|
pr_trim | s |
pr_hexval | c |
pr_unescape | s |
pr_split | ln |
pr_set | cfg, k, v |
pr_to_string | cfg |
pr_merge | cfg1, cfg2 |
pr_get_default | cfg, k, default |
pr_delete | cfg, k |
pr_values | cfg |
pr_len | cfg |
包内说明(源码头注释)
text
============================================================
普贤生态库:registry/properties —— Java .properties 解析
------------------------------------------------------------
纯函数库(无 IO、无状态),编译(px build)与解释(px run)双模式一致。
pr_parse(s) → Ok(dict) | Err 解析属性文本
pr_get(cfg, k) → Ok(str) | Err 取值(缺失 Err,响亮)
pr_has(cfg, k) → bool
pr_keys(cfg) → [str]
支持:
- 分隔符 `=` / `:` / 空白;键两侧与值首尾去空白
- 注释 `#` / `!` 开头整行;空行跳过
- 行续行(行尾单个反斜杠 + 下前行首空白去净)
- 值转义:\n \t \r \\ \: \= \ 空格;\uXXXX(Unicode)
============================================================