• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Matcher类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.simpleframework.xml.transform.Matcher的典型用法代码示例。如果您正苦于以下问题:Java Matcher类的具体用法?Java Matcher怎么用?Java Matcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Matcher类属于org.simpleframework.xml.transform包,在下文中一共展示了Matcher类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testStringMatcher

import org.simpleframework.xml.transform.Matcher; //导入依赖的package包/类
public void testStringMatcher() throws Exception {
   Matcher matcher = new ExampleStringMatcher();
   Serializer serializer = new Persister(matcher);
   EmptyStringExample original = new EmptyStringExample("", null);
   StringWriter writer = new StringWriter();
   
   serializer.write(original, writer);
   
   String text = writer.toString();
   System.out.println(text);
   
   EmptyStringExample recovered = serializer.read(EmptyStringExample.class, text);
   
   assertEquals(recovered.emptyValue, original.emptyValue);
   assertEquals(recovered.nullValue, original.nullValue);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:17,代码来源:MatcherTest.java


示例2: matchers

import org.simpleframework.xml.transform.Matcher; //导入依赖的package包/类
public static Matcher matchers() {
    return type -> {
        if (type.isEnum()) {
            return new EnumTransform(type);
        } else if (type.isInstance(LocalDate.now())) {
            return new LocalDateTransform();
        }
        return null;
    };
}
 
开发者ID:adleritech,项目名称:flexibee,代码行数:11,代码来源:Factory.java


示例3: createPersister

import org.simpleframework.xml.transform.Matcher; //导入依赖的package包/类
public static Persister createPersister(final Account account) {
    return new Persister(new Matcher() {
        @Override
        public Transform match(Class type) throws Exception {
            if (Date.class.isAssignableFrom(type)) {
                return new DateTransform(account);
            } else if (Uri.class.isAssignableFrom(type)) {
                return new UriTransform(account);
            }

            return null;
        }
    });
}
 
开发者ID:dyweb,项目名称:gitlab-android,代码行数:15,代码来源:SimpleXmlProvider.java


示例4: Support

import org.simpleframework.xml.transform.Matcher; //导入依赖的package包/类
/**
 * Constructor for the <code>Support</code> object. This will
 * create a support object with the matcher and filter provided.
 * This allows the user to override the transformations that
 * are used to convert types to strings and back again.
 * 
 * @param filter this is the filter to use with this support
 * @param matcher this is the matcher used for transformations
 * @param format this contains all the formatting for the XML
 */
public Support(Filter filter, Matcher matcher, Format format) {
   this.defaults = new DetailExtractor(this, FIELD);
   this.transform = new Transformer(matcher);
   this.scanners = new ScannerFactory(this);
   this.details = new DetailExtractor(this);
   this.labels = new LabelExtractor(format);
   this.instances = new InstanceFactory();
   this.matcher = matcher;
   this.filter = filter;
   this.format = format;
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:22,代码来源:Support.java


示例5: testLiteral

import org.simpleframework.xml.transform.Matcher; //导入依赖的package包/类
public void testLiteral() throws Exception {
   Matcher matcher = new LiteralMatcher();
   Persister persister = new Persister(matcher);
   LiteralExample example = new LiteralExample("name", "key");
   
   persister.write(example, System.out);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:8,代码来源:LiteralTest.java


示例6: testMatcher

import org.simpleframework.xml.transform.Matcher; //导入依赖的package包/类
public void testMatcher() throws Exception {
   Matcher matcher = new ExampleIntegerMatcher();
   Serializer serializer = new Persister(matcher);
   Example example = new Example(1, 9999);
   
   serializer.write(example, System.out);
 
   validate(serializer, example);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:10,代码来源:MatcherTest.java


示例7: testEnumMatcher

import org.simpleframework.xml.transform.Matcher; //导入依赖的package包/类
public void testEnumMatcher() throws Exception {
   Matcher matcher = new ExampleEnumMatcher();
   Serializer serializer = new Persister(matcher);
   ExampleEnum value = new ExampleEnum(MyEnum.A_1);
   StringWriter writer = new StringWriter();
   
   serializer.write(value, writer);
   
   assertElementHasAttribute(writer.toString(), "/exampleEnum", "value", "A-1");
   
   System.out.println(writer.toString());
   
   validate(serializer, value);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:15,代码来源:MatcherTest.java


示例8: Persister

import org.simpleframework.xml.transform.Matcher; //导入依赖的package包/类
/**
 * Constructor for the <code>Persister</code> object. This is used
 * to create a serializer object that will use the provided matcher
 * for customizable transformations. The <code>Matcher</code> will
 * enable the persister to determine the correct way to transform
 * the types that are not annotated and considered primitives.
 * <p>
 * This persister will use the provided <code>Strategy</code> to
 * intercept the XML elements in order to read and write persistent
 * data, such as the class name or version of the document.
 * 
 * @param strategy this is the strategy used to resolve classes 
 * @param matcher this is used to customize the transformations
 * @param filter the filter used to replace template variables
 */
public Persister(Strategy strategy, Filter filter, Matcher matcher, Format format) {
   this.support = new Support(filter, matcher, format);
   this.manager = new SessionManager();
   this.strategy = strategy;
   this.format = format;
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:22,代码来源:Persister.java



注:本文中的org.simpleframework.xml.transform.Matcher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ContainerExceptionMapProto类代码示例发布时间:2022-05-22
下一篇:
Java Value类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap