public Object unmarshal(QName type, Element data) throws JAXBException { return unmarshal(type, data, true); }
public Object unmarshalDefaultValue(ConfigurationItemMetadata item, Element data) { return unmarshalDefaultValue(item, data, false); }
public TypeSchema get(String namespaceURI, String base, String location) { TypeSchema ts = map.get(namespaceURI); if (null == ts) { ts = new TypeSchema(namespaceURI, base, location, forceDefaults); map.put(namespaceURI, ts); } return ts; }
private void deserialize(Document document) { deseralizePackageName(document); deserializeTypes(document); deserializeElements(document); }
InputSource is = getSchemaInputSource(baseURI, location); deserialize(document);
private void deserializeTypes(Document document) { Element root = document.getDocumentElement(); for (Node nd = root.getFirstChild(); nd != null; nd = nd.getNextSibling()) { if (Node.ELEMENT_NODE == nd.getNodeType() && ("simpleType".equals(nd.getLocalName()) || ("complexType".equals(nd.getLocalName())))) { String typeName = ((Element)nd).getAttribute("name"); String baseType = null; if ("simpleType".equals(nd.getLocalName())) { baseType = getBaseType(document, typeName); } if (!typeDefinitions.containsKey(typeName)) { typeDefinitions.put(typeName, baseType); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Added base type " + baseType + " for key: " + typeName); } } } } }
private String getBaseType(Document document, String typeName) { String currentType = typeName; QName baseType; do { baseType = getBaseTypeInternal(document, currentType); if (null == baseType) { LOG.severe(new Message("UNDEFINED_SIMPLE_TYPE_MSG", LOG, typeName).toString()); return null; } else if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(baseType.getNamespaceURI())) { if (LOG.isLoggable(Level.FINE)) { LOG.fine("Base type for " + typeName + ": " + baseType); } return baseType.getLocalPart(); } else if (!namespaceURI.equals(baseType.getNamespaceURI())) { LOG.severe(new Message("SIMPLE_TYPE_DEFINED_IN_OTHER_NAMESPACE_MSG", LOG, typeName, namespaceURI).toString()); return null; } currentType = baseType.getLocalPart(); } while (true); }
QName type = null; if (null != ts) { type = ts.getDeclaredType(elementName);
public Object getValue() { Object o = super.getValue(); if (o instanceof Element) { Element el = (Element)o; QName type = new QName(el.getNamespaceURI(), el.getLocalName()); TypeSchema ts = new TypeSchemaHelper(true).get(type.getNamespaceURI()); if (null == ts) { throw new ConfigurationException(new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type)); } try { return ts.unmarshal(type, el); } catch (JAXBException ex) { Message msg = new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type); throw new ConfigurationException(msg, ex); } } return o; } }
private void unmarshalDefaultValue(ConfigurationItemMetadataImpl item, Element data) { TypeSchema ts = new TypeSchemaHelper(forceDefaults).get(data.getNamespaceURI()); Object obj = ts.unmarshalDefaultValue(item, data, doValidate); if (null != obj) { item.setDefaultValue(obj); } } }
public Object getValue() { Object o = super.getValue(); if (o instanceof Element) { Element el = (Element)o; QName type = new QName(el.getNamespaceURI(), el.getLocalName()); TypeSchema ts = new TypeSchemaHelper(true).get(type.getNamespaceURI()); if (null == ts) { throw new ConfigurationException(new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type)); } try { return ts.unmarshal(type, el); } catch (JAXBException ex) { Message msg = new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type); throw new ConfigurationException(msg, ex); } } return o; }
Object obj = ts.unmarshalDefaultValue(mdi, (Element)node, doValidate); chains.add((HandlerChainType)obj);
public Object unmarshalDefaultValue(ConfigurationItemMetadata item, Element data, boolean doValidate) { try { return unmarshal(item.getType(), data, doValidate); } catch (JAXBException ex) { if (forceDefaults) { Message msg = new Message("DEFAULT_VALUE_UNMARSHAL_ERROR_EXC", LOG, item.getName()); throw new ConfigurationException(msg, ex); } return null; } }
public Object getValue() { Object o = super.getValue(); if (o instanceof Element) { Element el = (Element)o; QName type = new QName(el.getNamespaceURI(), el.getLocalName()); TypeSchema ts = new TypeSchemaHelper(true).get(type.getNamespaceURI()); if (null == ts) { throw new ConfigurationException(new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type)); } try { return ts.unmarshal(type, el); } catch (JAXBException ex) { Message msg = new Message("JAXB_PROPERTY_EDITOR_EXC", LOG, type); throw new ConfigurationException(msg, ex); } } return o; } }