1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wadl.inference.schema.types;
14
15 import org.apache.xmlbeans.XmlException;
16
17 import com.eviware.soapui.impl.wadl.inference.schema.Context;
18 import com.eviware.soapui.impl.wadl.inference.schema.Schema;
19 import com.eviware.soapui.impl.wadl.inference.schema.SchemaSystem;
20 import com.eviware.soapui.impl.wadl.inference.schema.Type;
21 import com.eviware.soapui.inferredSchema.TypeConfig;
22 import com.eviware.soapui.inferredSchema.TypeReferenceConfig;
23
24 /***
25 * This Type is simply a reference to another, actual Type. It is used when
26 * loading previously saved data, since the Type may not yet be loaded.
27 *
28 * @author Dain Nilsson
29 */
30 public class TypeReferenceType implements Type
31 {
32 String name;
33 String namespace;
34 SchemaSystem schemaSystem;
35
36 /***
37 * Constructs a new TypeReferenceType from previously saved data. Should be
38 * called in the Type.Factory.
39 */
40 public TypeReferenceType( TypeReferenceConfig xml, Schema schema )
41 {
42 schemaSystem = schema.getSystem();
43 name = xml.getReference().getLocalPart();
44 namespace = xml.getReference().getNamespaceURI();
45 }
46
47 public TypeConfig save()
48 {
49 return schemaSystem.getSchemaForNamespace( namespace ).getType( name ).save();
50 }
51
52 public String getName()
53 {
54 return name;
55 }
56
57 public Type validate( Context context ) throws XmlException
58 {
59 return schemaSystem.getSchemaForNamespace( namespace ).getType( name );
60 }
61
62 public Schema getSchema()
63 {
64 return schemaSystem.getSchemaForNamespace( namespace );
65 }
66
67 public void setSchema( Schema schema )
68 {
69 namespace = schema.getNamespace();
70 }
71
72 }