01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: * See the GNU Lesser General Public License for more details at gnu.org.
11: */
12:
13: package com.eviware.soapui.impl.wsdl.panels.request.components.editor.support;
14:
15: import org.apache.xmlbeans.SchemaTypeSystem;
16: import org.apache.xmlbeans.XmlBeans;
17: import org.apache.xmlbeans.XmlObject;
18:
19: /**
20: * Default XmlDocument that works on a standard xml string
21: *
22: * @author ole.matzura
23: */
24:
25: public class DefaultXmlDocument extends AbstractXmlDocument {
26: private String xml;
27: private SchemaTypeSystem typeSystem;
28:
29: public DefaultXmlDocument(String xml) {
30: this .xml = xml;
31: }
32:
33: public void setTypeSystem(SchemaTypeSystem typeSystem) {
34: this .typeSystem = typeSystem;
35: }
36:
37: public SchemaTypeSystem getTypeSystem() {
38: if (typeSystem != null)
39: return typeSystem;
40:
41: try {
42: typeSystem = XmlObject.Factory.parse(xml).schemaType()
43: .getTypeSystem();
44: return typeSystem;
45: } catch (Exception e) {
46: return XmlBeans.getBuiltinTypeSystem();
47: }
48: }
49:
50: public String getXml() {
51: return xml;
52: }
53:
54: public void setXml(String xml) {
55: String oldXml = this .xml;
56: this .xml = xml;
57: typeSystem = null;
58:
59: fireXmlChanged(oldXml, xml);
60: }
61:
62: public void release() {
63: typeSystem = null;
64: }
65: }
|