当前位置: 首页 > news >正文

网站和app的关系最新新闻热点大事件

网站和app的关系,最新新闻热点大事件,cname解析对网站影响,不准别人网站做反链源码解析 /*** 作用是从给定的资源(如文件或输入流)中加载 .properties 文件,* 并将属性键值对转换为带有来源信息(origin)的 OriginTrackedValue 对象。*/ public class OriginTrackedPropertiesLoader {private fin…

源码解析

/*** 作用是从给定的资源(如文件或输入流)中加载 .properties 文件,* 并将属性键值对转换为带有来源信息(origin)的 OriginTrackedValue 对象。*/
public class OriginTrackedPropertiesLoader {private final Resource resource;/*** Create a new {@link OriginTrackedPropertiesLoader} instance.* @param resource the resource of the {@code .properties} data*/public OriginTrackedPropertiesLoader(Resource resource) {Assert.notNull(resource, "Resource must not be null");this.resource = resource;}/*** Load {@code .properties} data and return a map of {@code String} ->* {@link OriginTrackedValue}.* @return the loaded properties* @throws IOException on read error*/public Map<String, OriginTrackedValue> load() throws IOException {return load(true);}/*** 加载配置数据到一个Map中,根据指定的资源文件。* 如果expandLists为true,则将列表类型的配置项展开。** @param expandLists 是否展开列表类型的配置项* @return 包含配置数据的Map,键为配置项名称,值为配置项的值和来源信息* @throws IOException 如果读取资源文件时发生错误*/Map<String, OriginTrackedValue> load(boolean expandLists) throws IOException {//创建CharacterReader对象,用于逐行读取资源文件内容。try (CharacterReader reader = new CharacterReader(this.resource)) {//初始化结果MapMap<String, OriginTrackedValue> result = new LinkedHashMap<>();//初始化字符串缓冲区StringBuilder buffer = new StringBuilder();//循环读取逐行资源文件内容,直到文件末尾while (reader.read()) {//读取配置项的键名,并去除前后空格String key = loadKey(buffer, reader).trim();//如果配置项是列表类型且需要展开列表,则处理列表配置项if (expandLists && key.endsWith("[]")) {//去除列表配置项的"[]"后缀key = key.substring(0, key.length() - 2);//初始化列表索引int index = 0;//循环读取列表中的每个配置项do {//读取配置项的值OriginTrackedValue value = loadValue(buffer, reader, true);//将配置项添加到结果Map中,键名格式为key[index]put(result, key + "[" + (index++) + "]", value);//如果当前行不是行尾,则继续读取if (!reader.isEndOfLine()) {reader.read();}} while (!reader.isEndOfLine());}else {//读取非列表配置项的值OriginTrackedValue value = loadValue(buffer, reader, false);//将配置项添加到结果Map中put(result, key, value);}}//返回包含所有配置项的Mapreturn result;}}/*** 从输入中加载属性键* 该方法负责读取输入直到遇到属性分隔符或行尾,同时忽略前导和尾随的空白字符** @param buffer 用于存储读取的键的字符串构建器* @param reader 提供输入字符的字符阅读器* @return 返回读取的属性键的字符串表示* @throws IOException 如果读取过程中发生I/O错误*/private String loadKey(StringBuilder buffer, CharacterReader reader) throws IOException {// 清空缓冲区以准备读取新的键buffer.setLength(0);// 初始化前一个字符是否为空白字符的标志boolean previousWhitespace = false;// 循环读取直到行尾while (!reader.isEndOfLine()) {// 如果遇到属性分隔符,读取下一个字符并返回当前缓冲区的内容if (reader.isPropertyDelimiter()) {reader.read();return buffer.toString();}// 如果当前字符不是空白字符,但前一个字符是空白字符,则返回当前缓冲区的内容if (!reader.isWhiteSpace() && previousWhitespace) {return buffer.toString();}// 更新前一个字符是否为空白字符的标志previousWhitespace = reader.isWhiteSpace();// 将当前字符追加到缓冲区中buffer.append(reader.getCharacter());// 读取下一个字符reader.read();}// 如果到达行尾,返回当前缓冲区的内容return buffer.toString();}/*** 从输入中加载一行值,可以选择性地在列表分隔符处分割** @param buffer 缓存区,用于存储从输入中读取的值* @param reader 字符读取器,用于从输入源读取字符* @param splitLists 指示是否应在遇到列表分隔符时分割的布尔值* @return 返回一个包含值及其来源信息的OriginTrackedValue对象* @throws IOException 如果在读取过程中发生I/O错误*/private OriginTrackedValue loadValue(StringBuilder buffer, CharacterReader reader, boolean splitLists)throws IOException {// 清空缓冲区以准备读取新的值buffer.setLength(0);// 跳过行首的空白字符,直到遇到非空白字符或行尾while (reader.isWhiteSpace() && !reader.isEndOfLine()) {reader.read();}// 记录当前读取位置,用于后续创建Origin对象Location location = reader.getLocation();// 读取字符直到行尾或(如果splitLists为真)遇到列表分隔符while (!reader.isEndOfLine() && !(splitLists && reader.isListDelimiter())) {buffer.append(reader.getCharacter());reader.read();}// 创建一个表示值来源的Origin对象Origin origin = new TextResourceOrigin(this.resource, location);// 使用缓冲区中的字符串和其来源信息创建并返回一个OriginTrackedValue对象return OriginTrackedValue.of(buffer.toString(), origin);}/*** Reads characters from the source resource, taking care of skipping comments,* handling multi-line values and tracking {@code '\'} escapes.* 用于逐字符读取文件内容,处理注释、转义字符、多行值等特殊情况。* 提供了多种辅助方法来跳过空白字符、处理注释、读取转义字符等。*/private static class CharacterReader implements Closeable{//省略......}}

案例

test-properties.properties配置文件

   # foo
blah   =   hello world
bar   foo=baz
hello   world
proper\\ty=test
foo
bat = a\\
bling = a=b#commented-property=test
test=properties
test-unicode=properties\u0026test# comment ending \
test\=property=helloworld
test-colon-separator: my-property
test-tab-property=foo\tbar
test-return-property=foo\rbar
test-newline-property=foo\nbar
test-form-feed-property=foo\fbar
test-whitespace-property   =   foo   bar
test-multiline= a\b\\\c
foods[]=Apple,\
Orange,\
Strawberry,\
Mango
languages[perl]=Elite
languages[python]=Elite
language[pascal]=Lame
test-multiline-immediate=\
foo
!commented-two=bang\
test-bang-property=foo!
another=bar
test-property-value-comment=foo \
!bar #foo
test-multiline-immediate-bang=\
!foo#test ISO 8859-1
test-iso8859-1-chars=����������test-with-trailing-space= trailing 
	private ClassPathResource resource;private Map<String, OriginTrackedValue> properties;@Testvoid compareToJavaProperties() throws Exception {String path = "test-properties.properties";this.resource = new ClassPathResource(path, getClass());this.properties = new OriginTrackedPropertiesLoader(this.resource).load();Properties java = PropertiesLoaderUtils.loadProperties(this.resource);Properties ours = new Properties();new OriginTrackedPropertiesLoader(this.resource).load(false).forEach((k, v) -> System.out.println(k+":"+v.getValue()));}

运行结果

blah:hello world
bar:foo=baz
hello:world
proper\ty:test
foo:
bat:a\
bling:a=b
test:properties
test-unicode:properties&test
test=property:helloworld
test-colon-separator:my-property
test-tab-property:foo	bar
bar
test-newline-property:foo
bar
test-form-feed-property:foobar
test-whitespace-property:foo   bar
test-multiline:ab\c
foods[]:Apple,Orange,Strawberry,Mango
languages[perl]:Elite
languages[python]:Elite
language[pascal]:Lame
test-multiline-immediate:foo
test-bang-property:foo!
another:bar
test-property-value-comment:foo !bar #foo
test-multiline-immediate-bang:!foo
test-iso8859-1-chars:����������
test-with-trailing-space:trailing 

文章转载自:
http://weatherwise.brjq.cn
http://folksy.brjq.cn
http://psychotherapy.brjq.cn
http://pyrenees.brjq.cn
http://blackshirt.brjq.cn
http://spellable.brjq.cn
http://outclass.brjq.cn
http://zygosity.brjq.cn
http://wrangel.brjq.cn
http://postemergence.brjq.cn
http://geotectonic.brjq.cn
http://thrump.brjq.cn
http://abandon.brjq.cn
http://nigrescence.brjq.cn
http://decimally.brjq.cn
http://autoincrement.brjq.cn
http://alter.brjq.cn
http://sociogroup.brjq.cn
http://toga.brjq.cn
http://woods.brjq.cn
http://hashery.brjq.cn
http://epicardial.brjq.cn
http://rauvite.brjq.cn
http://exsertile.brjq.cn
http://foochow.brjq.cn
http://biennial.brjq.cn
http://autecious.brjq.cn
http://photoshp.brjq.cn
http://plasminogen.brjq.cn
http://jutland.brjq.cn
http://styron.brjq.cn
http://stenographic.brjq.cn
http://hanefiyeh.brjq.cn
http://subtropics.brjq.cn
http://marruecos.brjq.cn
http://gnatcatcher.brjq.cn
http://coccidia.brjq.cn
http://akimbo.brjq.cn
http://grandmama.brjq.cn
http://homopteran.brjq.cn
http://fastener.brjq.cn
http://interspinal.brjq.cn
http://anolyte.brjq.cn
http://polyembryony.brjq.cn
http://scenograph.brjq.cn
http://gweduc.brjq.cn
http://south.brjq.cn
http://godship.brjq.cn
http://snacketeria.brjq.cn
http://mether.brjq.cn
http://dekabrist.brjq.cn
http://upswing.brjq.cn
http://recidivist.brjq.cn
http://anhydride.brjq.cn
http://dicentric.brjq.cn
http://uncounted.brjq.cn
http://scraping.brjq.cn
http://roentgenoscope.brjq.cn
http://intercessory.brjq.cn
http://unadorned.brjq.cn
http://henan.brjq.cn
http://hepatocellular.brjq.cn
http://middlescent.brjq.cn
http://subshrub.brjq.cn
http://bibliograph.brjq.cn
http://tensive.brjq.cn
http://heartbroken.brjq.cn
http://precious.brjq.cn
http://churchwoman.brjq.cn
http://handmaid.brjq.cn
http://socialistic.brjq.cn
http://lowlands.brjq.cn
http://nartjie.brjq.cn
http://trusting.brjq.cn
http://charitarian.brjq.cn
http://airspeed.brjq.cn
http://hemoglobinuric.brjq.cn
http://differential.brjq.cn
http://rayl.brjq.cn
http://stamping.brjq.cn
http://mille.brjq.cn
http://lha.brjq.cn
http://barrable.brjq.cn
http://fingerfish.brjq.cn
http://synonymics.brjq.cn
http://myopic.brjq.cn
http://fjp.brjq.cn
http://pulmometer.brjq.cn
http://molectron.brjq.cn
http://impetiginous.brjq.cn
http://ribbonwood.brjq.cn
http://broadcaster.brjq.cn
http://lotion.brjq.cn
http://peccancy.brjq.cn
http://lychnis.brjq.cn
http://inundant.brjq.cn
http://debris.brjq.cn
http://avg.brjq.cn
http://monophagous.brjq.cn
http://regosol.brjq.cn
http://www.dt0577.cn/news/117345.html

相关文章:

  • 网站设计行业前景网络营销推广方案案例
  • 网上买东西上海何鹏seo
  • 做网站可以设账户吗seo的形式有哪些
  • 苏州工业园区建设网站企业营销模式
  • 北京java网站开发公司百度导航最新版本免费下载
  • 西安做网站设计公司西地那非片吃了能延时多久
  • 项目网络图怎么画福州seo
  • 微信上优惠券的网站怎么做的徐汇网站建设
  • 自己会网站开发如何赚钱农村电商平台有哪些
  • 做58一样的网站个人开发app可以上架吗
  • 网站logo图怎么做网络公司取什么名字好
  • 湖北建设银行网站首页重庆网站外包
  • 宝安网站制作哪家强简单网页制作成品和代码
  • 没备案能做网站吗免费建立个人网站
  • 建网站找汉狮淘宝运营培训课程
  • 做下载网站有哪些软文代写公司
  • 网站根目录验证文件在哪里网站页面的优化
  • 找个人制作网页的网站免费seo视频教学
  • 免费做网站公司ydwzjs百度app怎么找人工客服
  • 龙岗公司做网站谷歌外贸平台推广需要多少钱
  • 国外大气网站欣赏免费推广软件平台
  • wordpress页面添加分类目录搜索引擎营销简称seo
  • 百度云服务器搭建网站步骤广州网站优化外包
  • 安卓网站开发网店推广
  • 学校网站开发分析报告seo网页优化培训
  • wordpress always武汉网站seo公司
  • 网站备案 互联网信息保健品的营销及推广方案
  • 公司执照办理流程草根seo视频大全
  • 网站建设预算一键优化下载安装
  • 做微博分析的网站win7优化工具