Java 类org.simpleframework.xml.transform.Matcher 实例源码

项目:simplexml    文件:MatcherTest.java   
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);
}
项目:simple-xml    文件:MatcherTest.java   
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);
}
项目:flexibee    文件:Factory.java   
public static Matcher matchers() {
    return type -> {
        if (type.isEnum()) {
            return new EnumTransform(type);
        } else if (type.isInstance(LocalDate.now())) {
            return new LocalDateTransform();
        }
        return null;
    };
}
项目:gitlab-android    文件:SimpleXmlProvider.java   
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;
        }
    });
}
项目:simplexml    文件:Support.java   
/**
 * 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;
}
项目:simplexml    文件:LiteralTest.java   
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);
}
项目:simplexml    文件:MatcherTest.java   
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);
}
项目:simplexml    文件:MatcherTest.java   
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);
}
项目:simple-xml    文件:Support.java   
/**
 * 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;
}
项目:simple-xml    文件:LiteralTest.java   
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);
}
项目:simple-xml    文件:MatcherTest.java   
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);
}
项目:simple-xml    文件:MatcherTest.java   
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);
}
项目:simplexml    文件:Persister.java   
/**
 * 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;
}
项目:simple-xml    文件:Persister.java   
/**
 * 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;
}
项目:simplexml    文件:Persister.java   
/**
 * 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.
 * 
 * @param matcher this is used to customize the transformations
 */
public Persister(Matcher matcher) {
   this(new TreeStrategy(), matcher);
}
项目:simplexml    文件:Persister.java   
/**
 * 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.
 * 
 * @param matcher this is used to customize the transformations
 * @param format this is used to structure the generated XML
 */
public Persister(Matcher matcher, Format format) {
   this(new TreeStrategy(), matcher, format);
}
项目:simplexml    文件:Persister.java   
/**
 * Constructor for the <code>Persister</code> object. This is used
 * to create a serializer object that will use the provided filter.
 * This persister will replace all variables encountered when
 * deserializing an object with mappings found in the filter.
 * 
 * @param filter the filter used to replace template variables
 * @param matcher this is used to customize the transformations
 */
public Persister(Filter filter, Matcher matcher) {
   this(new TreeStrategy(), filter, matcher);
}
项目:simplexml    文件:Persister.java   
/**
 * Constructor for the <code>Persister</code> object. This is used
 * to create a serializer object that will use the provided filter.
 * This persister will replace all variables encountered when
 * deserializing an object with mappings found in the filter.
 * 
 * @param filter the filter used to replace template variables
 * @param matcher this is used to customize the transformations
 * @param format this is used to structure the generated XML
 */
public Persister(Filter filter, Matcher matcher, Format format) {
   this(new TreeStrategy(), filter, matcher, format);
}
项目:simplexml    文件:Persister.java   
/**
 * 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
 */
public Persister(Strategy strategy, Matcher matcher) {
   this(strategy, new PlatformFilter(), matcher);
}
项目:simplexml    文件:Persister.java   
/**
 * 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 format this is used to format the generated XML document
 */
public Persister(Strategy strategy, Matcher matcher, Format format) {
   this(strategy, new PlatformFilter(), matcher, format);
}
项目:simplexml    文件:Persister.java   
/**
 * 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) {
   this(strategy, filter, matcher, new Format());
}
项目:simplexml    文件:Support.java   
/**
 * 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
 */
public Support(Filter filter, Matcher matcher) {
   this(filter, matcher, new Format());
}
项目:simple-xml    文件:Persister.java   
/**
 * 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.
 * 
 * @param matcher this is used to customize the transformations
 */
public Persister(Matcher matcher) {
   this(new TreeStrategy(), matcher);
}
项目:simple-xml    文件:Persister.java   
/**
 * 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.
 * 
 * @param matcher this is used to customize the transformations
 * @param format this is used to structure the generated XML
 */
public Persister(Matcher matcher, Format format) {
   this(new TreeStrategy(), matcher, format);
}
项目:simple-xml    文件:Persister.java   
/**
 * Constructor for the <code>Persister</code> object. This is used
 * to create a serializer object that will use the provided filter.
 * This persister will replace all variables encountered when
 * deserializing an object with mappings found in the filter.
 * 
 * @param filter the filter used to replace template variables
 * @param matcher this is used to customize the transformations
 */
public Persister(Filter filter, Matcher matcher) {
   this(new TreeStrategy(), filter, matcher);
}
项目:simple-xml    文件:Persister.java   
/**
 * Constructor for the <code>Persister</code> object. This is used
 * to create a serializer object that will use the provided filter.
 * This persister will replace all variables encountered when
 * deserializing an object with mappings found in the filter.
 * 
 * @param filter the filter used to replace template variables
 * @param matcher this is used to customize the transformations
 * @param format this is used to structure the generated XML
 */
public Persister(Filter filter, Matcher matcher, Format format) {
   this(new TreeStrategy(), filter, matcher, format);
}
项目:simple-xml    文件:Persister.java   
/**
 * 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
 */
public Persister(Strategy strategy, Matcher matcher) {
   this(strategy, new PlatformFilter(), matcher);
}
项目:simple-xml    文件:Persister.java   
/**
 * 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 format this is used to format the generated XML document
 */
public Persister(Strategy strategy, Matcher matcher, Format format) {
   this(strategy, new PlatformFilter(), matcher, format);
}
项目:simple-xml    文件:Persister.java   
/**
 * 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) {
   this(strategy, filter, matcher, new Format());
}
项目:simple-xml    文件:Support.java   
/**
 * 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
 */
public Support(Filter filter, Matcher matcher) {
   this(filter, matcher, new Format());
}