Java 类org.simpleframework.xml.filter.Filter 实例源码

项目:simplexml    文件:FilterTest.java   
public void testEnvironmentFilter() throws Exception {
   Filter filter = new EnvironmentFilter(null);           
   Persister persister = new Persister(filter);
   Entry entry = persister.read(Entry.class, new StringReader(ENTRY));

   assertEquals(entry.number, 1234);
   assertEquals(entry.bool, true);
   assertEquals(entry.name, "${example.name}");
   assertEquals(entry.path, "${example.path}");

   Filter systemFilter = new SystemFilter();
   Filter environmentFilter = new EnvironmentFilter(systemFilter);
   Persister environmentPersister = new Persister(environmentFilter);
   Entry secondEntry = environmentPersister.read(Entry.class, new StringReader(ENTRY));

   assertEquals(secondEntry.number, 1234);
   assertEquals(secondEntry.bool, true);
   assertEquals(secondEntry.name, "some name");
   assertEquals(secondEntry.path, "/some/path");
   assertEquals(secondEntry.constant, "some constant");      

}
项目:simplexml    文件:PathWithTemplateTest.java   
public void testPathWithTemplates() throws Exception {
   Map<String, String> map = new HashMap<String, String>();
   map.put("name", "Jack Daniels");
   map.put("age", "22");
   map.put("sex", "MALE");
   map.put("city", "London");
   map.put("street", "Old Street");
   map.put("mobile", "12345");
   map.put("home", "67890");
   map.put("area", "+44");
   Filter filter = new MapFilter(map);
   Persister persister = new Persister(filter);
   PathWithTemplateExample example = persister.read(PathWithTemplateExample.class, SOURCE);
   assertEquals(example.area, "+44");
   assertEquals(example.name, "Jack Daniels");
   assertEquals(example.sex, Sex.MALE);
   assertEquals(example.age, 22);
   assertEquals(example.city, "London");
   assertEquals(example.mobile, "12345");
   assertEquals(example.home, "67890");
   assertEquals(example.street, "Old Street");
   persister.write(example, System.err);
   validate(example, persister);
}
项目:simple-xml    文件:FilterTest.java   
public void testEnvironmentFilter() throws Exception {
   Filter filter = new EnvironmentFilter(null);           
   Persister persister = new Persister(filter);
   Entry entry = persister.read(Entry.class, new StringReader(ENTRY));

   assertEquals(entry.number, 1234);
   assertEquals(entry.bool, true);
   assertEquals(entry.name, "${example.name}");
   assertEquals(entry.path, "${example.path}");

   Filter systemFilter = new SystemFilter();
   Filter environmentFilter = new EnvironmentFilter(systemFilter);
   Persister environmentPersister = new Persister(environmentFilter);
   Entry secondEntry = environmentPersister.read(Entry.class, new StringReader(ENTRY));

   assertEquals(secondEntry.number, 1234);
   assertEquals(secondEntry.bool, true);
   assertEquals(secondEntry.name, "some name");
   assertEquals(secondEntry.path, "/some/path");
   assertEquals(secondEntry.constant, "some constant");      

}
项目:simple-xml    文件:PathWithTemplateTest.java   
public void testPathWithTemplates() throws Exception {
   Map<String, String> map = new HashMap<String, String>();
   map.put("name", "Jack Daniels");
   map.put("age", "22");
   map.put("sex", "MALE");
   map.put("city", "London");
   map.put("street", "Old Street");
   map.put("mobile", "12345");
   map.put("home", "67890");
   map.put("area", "+44");
   Filter filter = new MapFilter(map);
   Persister persister = new Persister(filter);
   PathWithTemplateExample example = persister.read(PathWithTemplateExample.class, SOURCE);
   assertEquals(example.area, "+44");
   assertEquals(example.name, "Jack Daniels");
   assertEquals(example.sex, Sex.MALE);
   assertEquals(example.age, 22);
   assertEquals(example.city, "London");
   assertEquals(example.mobile, "12345");
   assertEquals(example.home, "67890");
   assertEquals(example.street, "Old Street");
   persister.write(example, System.err);
   validate(example, persister);
}
项目: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;
}
项目: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;
}
项目: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;
}
项目:simplexml    文件:TemplateEngine.java   
/**
 * Constructor for the <code>TemplateEngine</code> object. This is 
 * used to create a parsing buffer, which can be used to replace
 * filter variable names with their corrosponding values.
 * 
 * @param filter this is the filter used to provide replacements 
 */ 
public TemplateEngine(Filter filter) {
   this.source = new Template();
   this.name = new Template();            
   this.text = new Template();
   this.filter = filter;
}
项目: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;
}
项目:simple-xml    文件:TemplateEngine.java   
/**
 * Constructor for the <code>TemplateEngine</code> object. This is 
 * used to create a parsing buffer, which can be used to replace
 * filter variable names with their corrosponding values.
 * 
 * @param filter this is the filter used to provide replacements 
 */ 
public TemplateEngine(Filter filter) {
   this.source = new Template();
   this.name = new Template();            
   this.text = new Template();
   this.filter = filter;
}
项目:simplexml    文件:TemplateFilter.java   
/**
 * Constructor for the <code>TemplateFilter</code> object. This
 * creates a filter object that acquires template values from
 * two different contexts. Firstly the <code>Context</code> is
 * queried for a variables followed by the <code>Filter</code>.
 *
 * @param context this is the context object for the persister
 * @param filter the filter that has been given to the persister
 */ 
public TemplateFilter(Context context, Filter filter) {
   this.context = context;     
   this.filter = filter;      
}
项目: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
 */
public Persister(Filter filter) {
   this(new TreeStrategy(), filter);
}
项目: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 format this is used to structure the generated XML
 */
public Persister(Filter filter, Format format) {
   this(new TreeStrategy(), filter, 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 filter.
 * This persister will replace all variables encountered when
 * deserializing an object with mappings found in the filter.
 * <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 filter the filter used to replace template variables
 */
public Persister(Strategy strategy, Filter filter) {
   this(strategy, filter, new 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.
 * <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 filter the filter used to replace template variables
 * @param format this is used to format the generated XML document
 */
public Persister(Strategy strategy, Filter filter, Format format) {
   this(strategy, filter, new EmptyMatcher(), 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 a default matcher and the filter
 * provided. This ensures it contains enough information to 
 * process a template and transform basic primitive types.
 * 
 * @param filter this is the filter to use with this support
 */
public Support(Filter filter) {
   this(filter, new EmptyMatcher());
}
项目: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    文件:TemplateFilter.java   
/**
 * Constructor for the <code>TemplateFilter</code> object. This
 * creates a filter object that acquires template values from
 * two different contexts. Firstly the <code>Context</code> is
 * queried for a variables followed by the <code>Filter</code>.
 *
 * @param context this is the context object for the persister
 * @param filter the filter that has been given to the persister
 */ 
public TemplateFilter(Context context, Filter filter) {
   this.context = context;     
   this.filter = filter;      
}
项目: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
 */
public Persister(Filter filter) {
   this(new TreeStrategy(), filter);
}
项目: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 format this is used to structure the generated XML
 */
public Persister(Filter filter, Format format) {
   this(new TreeStrategy(), filter, 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 filter.
 * This persister will replace all variables encountered when
 * deserializing an object with mappings found in the filter.
 * <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 filter the filter used to replace template variables
 */
public Persister(Strategy strategy, Filter filter) {
   this(strategy, filter, 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 filter.
 * This persister will replace all variables encountered when
 * deserializing an object with mappings found in the filter.
 * <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 filter the filter used to replace template variables
 * @param format this is used to format the generated XML document
 */
public Persister(Strategy strategy, Filter filter, Format format) {
   this(strategy, filter, new EmptyMatcher(), 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 a default matcher and the filter
 * provided. This ensures it contains enough information to 
 * process a template and transform basic primitive types.
 * 
 * @param filter this is the filter to use with this support
 */
public Support(Filter filter) {
   this(filter, new EmptyMatcher());
}
项目: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());
}