KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thaiopensource > validate > AbstractSchema


1 package com.thaiopensource.validate;
2
3 import com.thaiopensource.util.PropertyMap;
4 import com.thaiopensource.util.PropertyId;
5 import com.thaiopensource.util.PropertyMapBuilder;
6
7 public abstract class AbstractSchema implements Schema {
8   private final PropertyMap properties;
9
10   public AbstractSchema() {
11     this(PropertyMap.EMPTY);
12   }
13
14   public AbstractSchema(PropertyMap properties) {
15     this.properties = properties;
16   }
17
18   public AbstractSchema(PropertyMap properties, PropertyId[] supportedPropertyIds) {
19     this(filterProperties(properties, supportedPropertyIds));
20   }
21
22   public PropertyMap getProperties() {
23     return properties;
24   }
25
26   static public PropertyMap filterProperties(PropertyMap properties, PropertyId[] supportedPropertyIds) {
27     PropertyMapBuilder builder = new PropertyMapBuilder();
28     for (int i = 0; i < supportedPropertyIds.length; i++) {
29       Object JavaDoc value = properties.get(supportedPropertyIds[i]);
30       if (value != null)
31         builder.put(supportedPropertyIds[i], value);
32     }
33     return builder.toPropertyMap();
34   }
35 }
36
Popular Tags